ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

Μέγεθος: px
Εμφάνιση ξεκινά από τη σελίδα:

Download "ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ"

Transcript

1 ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ Κωδικός Θ: ΤΠ3001, Κωδικός Ε: ΤΠ3101 (ΜΕΥ/Υ) Ώρες (Θ - Ε): 4-2 Προαπαιτούμενα: Δρ. ΒΙΔΑΚΗΣ ΝΙΚΟΣ

2 ΕΡΓΑΣΤΗΡΙΟ 4 Ταξινόμηση με 1. Bubble Sort 2. Quick Sort

3 Bubble Sort Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 3

4 Bubble Sort Introduction Bubble sort is also known as exchange sort. Bubble sort is the simplest sorting algorithm. In bubble sort algorithm array is traversed from 0 to the length-1 index of the array and compared one element to the next element and swap values in between if the next element is less than the previous element. In other words, bubble sorting algorithm compare two values and put the largest value at largest index. The algorithm follow the same steps repeatedly until the values of array is sorted. In practice it is used rarely and its main application is to make an introduction to the sorting algorithms In worst-case the complexity of bubble sort is O(n2) and in best-case the complexity of bubble sort is Ω(n). Quite inefficient for sorting large data volumes. Bubble sort is stable and adaptive Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 4

5 Bubble Sort Code description: Bubble Sorting is an algorithm in which we are comparing first two values and put the larger one at higher index. Then we take next two values compare these values and place larger value at higher index. This process do iteratively until the largest value is not reached at last index. Then start again from zero index up to n-1 index. The algorithm follows the same steps iteratively unlit elements are sorted. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 5

6 Bubble Sort algorithm working sequence Working of bubble sort algorithm: Ας θεωρήσουμε το unsorted array A[0],A[1],A[2]... A[n-1],A[n]. Βήματα ταξινόμησης αλγόριθμου bubble sort. 1. Compare A[0] and A[1]. 2. If A[0]>A[1] then Swap A[0] and A[1]. 3. Take next A[1] and A[2]. 4. Comapre these values. 5. If A[1]>A[2] then swap A[1] and A[2] at last compare A[n-1] and A[n]. 8. If A[n-1]>A[n] then swap A[n-1] and A[n]. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 6

7 Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 1: every step is a comparison (j=1) a. Compare first two values 12 and 9. b. 12, 9, 4, 99, 120, 1, 3, 10 c. 12>9 thus swap these values d. Then the new sequence will be e. 9, 12, 4, 99, 120, 1, 3, 10 Step 2: every step is j++ (j=2) a. take next two values 12 and 4 b. 9, 12, 4, 99, 120, 1, 3, 10 c. Compare these two values. d. 12>4 thus swap these values. e. Then the new sequence will be f. 9, 4, 12, 99, 120, 1, 3, 10 Steps 3-7: Follow similar steps up to end of array <99 ok <120 ok <120 ok >3 swap >10 swap Bubble Sort Working of bubble sort algorithm Example First loop i = 0: for(i = 0; i < n; i++) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS new order in array = End of the array Array is UNSORTED Start Again Second loop: for(j = 1; j < (n-i); j++) j = 3, n = 8, i = 0 (with j < (n-i) && i < n) j = 4, n = 8, i = 0 (with j < (n-i) && i < n) j = 5, n = 8, i = 0 (with j < (n-i) && i < n) j = 6, n = 8, i = 0 (with j < (n-i) && i < n) j = 7, n = 8, i = 0 (with j < (n-i) && i < n) Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 7

8 Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Steps 8-13: Follow similar steps up to end of array >4 swap <12 ok <99 ok Bubble Sort Working of bubble sort algorithm Example >1 swap >3 swap >10 swap public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; First loop in code for(i = 0; i < n; i++) (with i = 1) Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<7;j++) j = 1, n = 8, i = 1 (with j < (n-i) && i < n) j = 2, n = 8, i = 1 (with j < (n-i) && i < n) j = 3, n = 8, i = 1 (with j < (n-i) && i < n) j = 4, n = 8, i = 1 (with j < (n-i) && i < n) j = 5, n = 8, i = 1 (with j < (n-i) && i < n) j = 6, n = 8, i = 1 (with j < (n-i) && i < n) RESULTS (for 2 nd pass where i=1) 2 nd pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 8

9 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 First loop in code for(i = 0; i < n; i++) (with i = 2) Steps 14-18: Follow similar steps up to end of array <9 ok <12 ok >1 swap >3 swap >10 swap Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<6;j++) j = 1, n = 8, i = 2 (with j < (n-i) && i < n) j = 2, n = 8, i = 2 (with j < (n-i) && i < n) j = 3, n = 8, i = 2 (with j < (n-i) && i < n) j = 4, n = 8, i = 2 (with j < (n-i) && i < n) j = 5, n = 8, i = 2 (with j < (n-i) && i < n) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS (for 3 rd pass where i=2) 3 rd pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 9

10 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 First loop in code for(i = 0; i < n; i++) (with i = 3) Steps 19-22: Follow similar steps up to end of array <9 ok >1 swap >3 swap <10 ok Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<5;j++) j = 1, n = 8, i = 3 (with j < (n-i) && i < n) j = 2, n = 8, i = 3 (with j < (n-i) && i < n) j = 3, n = 8, i = 3 (with j < (n-i) && i < n) j = 4, n = 8, i = 3 (with j < (n-i) && i < n) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS (for 4 th pass where i=3) 4 th pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 10

11 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 First loop in code for(i = 0; i < n; i++) (with i = 4) Steps 23-25: Follow similar steps up to end of array >1 swap >3 swap <9 ok Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<4;j++) j = 1, n = 8, i = 4 (with j < (n-i) && i < n) j = 2, n = 8, i = 4 (with j < (n-i) && i < n) j = 3, n = 8, i = 4 (with j < (n-i) && i < n) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS (for 5 th pass where i=4) 5 th pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 11

12 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 First loop in code for(i = 0; i < n; i++) (with i = 5) Steps 26-27: Follow similar steps up to end of array <3 ok <4 ok Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<3;j++) j = 1, n = 8, i = 5 (with j < (n-i) && i < n) j = 2, n = 8, i = 5 (with j < (n-i) && i < n) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS (for 6 th pass where i=5) 6 th pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 12

13 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 First loop in code for(i = 0; i < n; i++) (with i = 6) Steps 28: Follow similar steps up to end of array <3 ok Second loop in code for(j = 1; j < (n-i); j++) translates to for (j=1; j<2;j++) j = 1, n = 8, i = 6 (with j < (n-i) && i < n) public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; RESULTS (for 7 th pass where i=6) 7 th pass element order = End of unsorted array reached and array is UNSORTED i++ Start Again Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 13

14 Bubble Sort Working of bubble sort algorithm Example Example array values: 12, 9, 4, 99, 120, 1, 3, 10 Steps 29 and 30 do not change anything in the arrays, so they don t count as COMPARES. They are just to demonstrate the function of the outer FOR loop and the exit of the bubble_srt( ) function. Step 29: No comparison in this step j = 1 n = 8 i = 7 with j < (n-i) && i < n; In every end of array i++ ; Step 30: No comparison in this step j = 1 n = 8 i = 8 with j < (n-i) && i < n; Now it exits the function Sorted array values: 1, 3, 4, 9, 10, 12, 99, 120, Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 14

15 Turtles and rabbits Bubble Sort One more problem of bubble sort is that its running time badly depends on the initial order of the elements. Big elements (rabbits) go up fast, while small ones (turtles) go down very slow. This problem is solved in the Cocktail sort. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 15

16 Bubble Sort Working of bubble sort algorithm Turtle Example Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 16

17 Bubble Sort Working of bubble sort algorithm Rabbit Example Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 17

18 Bubble Sort Example code in Java public class bubblesort{ public static void main(string a[]){ int i; int array[] = {12,9,4,99,120,1,3,10; System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); bubble_srt(array, array.length); System.out.print("Values after the sort:\n"); for(i = 0; i <array.length; i++) System.out.print(array[i]+" "); System.out.println(); System.out.println("PAUSE"); public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; Example code taken from: Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 18

19 Bubble Sort Example code in C++ public class bubblesort{ void bubblesort(int arr[], int n) { bool swapped = true; int j = 0; int tmp; while (swapped) { swapped = false; j++; for (int i = 0; i < n - j; i++) { if (arr[i] > arr[i + 1]) { tmp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = tmp; swapped = true; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 19

20 Bubble Sort Example code in C /* Bubble sort code */ #include <stdio.h> main() { int array[100], n, c, d, swap; printf("enter number of elements\n"); scanf("%d", &n); printf("enter %d integers\n", n); for (c = 0; c < n; c++) scanf("%d", &array[c]); for (c = 0 ; c < ( n - 1 ); c++) { for (d = 0 ; d < n - c - 1; d++) { if (array[d] > array[d+1]) /* For decreasing order use < */ { swap = array[d]; array[d] = array[d+1]; array[d+1] = swap; printf("sorted list in ascending order:\n"); for ( c = 0 ; c < n ; c++ ) printf("%d\n", array[c]); Copyrights: Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 20

21 Bidirectional Bubble Sort Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 21

22 Bidirectional Bubble Sort Introduction: Bi-directional bubble sorting also known as cocktail shaker sort, shaker sort, double-direction bubble sort. Facts: A alternative of bubble sort is bi-directional bubble sort. The bi-directional bubble sort compares each adjacent pair of elements in an array. The values will be swap if necessary. The values passes from the beginning to the end and also from the end to the beginning. It stops when there is no any element to swap. The complexity of bi-directional bubble sort is O(n2). Bi-directional bubble sort is better than bubble sort. In Bi-directional bubble sort at least one elements is moved forward or backward to its place in the array with each pass. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 22

23 Bidirectional Bubble Sort algorithm working sequence Working of bubble sort algorithm: Ας θεωρήσουμε το unsorted array A[0],A[1],A[2]... A[n-1],A[n]. Βήματα ταξινόμησης αλγόριθμου bubble sort. 1. Compare A[0] &A[1] and A[n-1] & A[n]. 2. If A[0]>A[1] then Swap A[0] & A[1] and also if A[n-1]>A[n] then swap it. 3. Take next A[1] & A[2] and A[n-2] & A[n-1]. 4. Comapre these values. 5. If A[1]>A[2] then Swap A[1] & A[2] and also if A[n-2]>A[n-1] then swap it Stop: when there is no any pass for swap or the array values are in sorted order. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 23

24 Bidirectional Bubble Sort public class BidirectionalBubbleSort{ public static void main(string a[]){ int i; int array[] = {12,9,4,99,120,1,3,10; System.out.println("\n\n RoseIndia\n\n"); System.out.println(" Bidirectional Bubble Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); bidirectionalbubble_srt(array, array.length); System.out.print("Values after the sort:\n"); for(i = 0; i <array.length; i++) System.out.print(array[i]+" "); System.out.println(); System.out.println("PAUSE"); Example code public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Example code taken from: Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 24

25 Bidirectional Bubble Sort Παράδειγμα σε C /* * C Program to Implement CockTail Sort */ #include <stdio.h> #define MAX 8 int main() { int data[max]; int i, j, n, c; printf("\nenter the data"); for (i = 0; i < MAX; i++) { scanf("%d", &data[i]); n = MAX; do { /* * Rightward pass will shift the largest element to its correct place at the end */ for (i = 0; i < n - 1; i++) { if (data[i] > data[i + 1]) { data[i] = data[i] + data[i + 1]; data[i + 1] = data[i] - data[i + 1]; data[i] = data[i] - data[i + 1]; n = n - 1; /* * Leftward pass will shift the smallest element to its correct place at the beginning */ for (i= MAX - 1, c = 0; i >= c; i--) { if(data[i] < data[i - 1]) { data[i] = data[i] + data[i - 1]; data[i - 1] = data[i] - data[i - 1]; data[i] = data[i] - data[i - 1]; c = c + 1; while (n!= 0 && c!= 0); printf("the sorted elements are:"); for (i = 0; i < MAX; i++) { printf("%d\t", data[i]); Copyrights: Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 25

26 Bidirectional Bubble Sort Working of bubble sort algorithm Example Example array values: 12, 9, 4, 99, 120, 1, 3, 10 Steps 1-7: Start to End Direction >9 swap >4 swap <99 ok <120 ok >1 swap >3 swap >10 swap new temp array = Steps 7-14: End to Start Direction <120 ok <10 ok <3 ok >1 swap >1 swap >1 swap >1 swap Steps 15-19: Start to End Direction >4 swap >12 ok >99 ok >3 swap >10 swap new temp array = Steps 20-24: End to Start Direction <99 ok <10 ok >3 swap >3 swap >3 swap new array = new array = Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 26

27 Bidirectional Bubble Sort Working of bubble sort algorithm Example Example array values: 12, 9, 4, 99, 120, 1, 3, 10 Steps 25-27: Start to End Direction <9 ok <12 ok >10 swap New temp array = Steps 28-30: End to Start Direction <12 ok <10 ok <9 ok new array = Step 31: Start to End Direction <10 ok new temp array = Step 32: End to Start Direction <12 ok new array = sorted So we have 32 steps Sorted array values: 1, 3, 4, 9, 10, 12, 99, 120, Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 27

28 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Begin the bidirectionalbubble_srt() with st = -1 Before Step1 and before entering the FOR loops, it checks the WHILE statement. Then it adds 1 to the st variable. So st = 0; And it subtracks 1 from the n variable. So n = 7 Steps 1-7: Start to End Direction j = st j = 0; so it starts comparing from: array[0] >9 swap >4 swap <99 ok <120 ok >1 swap >3 swap >10 swap And stop after 7 loops because j must be < than n so j < 7 new temp array: NEXT 2 PAGES STEP 1 4 WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 28

29 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 1: From Start To End. We are in 1 st FOR loop with n=7, st=0, j=0 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[0]>Array[1] Inside the IF it SWAPS the values of the array >9 swap j++; New Array: This loops for j<n, which means j < 7. Step 2: From Start To End. We are in 1 st FOR loop with n=7, st=0, j=1 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[1]>Array[2] Inside the IF it SWAPS the values of the array >4 swap j++; New Array: This loops for j<n, which means j < 7. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 29

30 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 3: From Start To End. We are in 1 st FOR loop with n=7, st=0, j=2 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[2]>Array[3] Inside the IF it SWAPS the values of the array <99 ok j++; New Array: This loops for j<n, which means j < 7. Step 4: From Start To End. We are in 1 st FOR loop with n=7, st=0, j=3 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array <120 ok j++; New Array: This loops for j<n, which means j < 7. SAME STEPS FOR J < N public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 30

31 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 st = 0; n = 7 First subtrack 1 from j then check if j >= st So, the starting value of j (j = n) will NOT be 7 but 6. Steps 8-14: End to Start Direction j=n j 7 but j j=6; so it starts comparing from array[6] > array[7] <120 ok j= <10 ok j= <3 ok j= >1 swap j= >1 swap j= >1 swap j= >1 swap j=0 And stops after 7 loops because j >= st; j >= 0; new array = NEXT 2 PAGES STEP 8 11 WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 31

32 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 8: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=7, j=n, st=0, j=6 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[6]>Array[7] Inside the IF it SWAPS the values of the array <120 ok New Array: This loops for j>=st, which means j >= 0. Step 9: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=7, st=0, j=5 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[5]>Array[6] Inside the IF it SWAPS the values of the array <10 ok New Array: This loops for j>=st, which means j >= 0. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 32

33 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 10: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=7, st=0, j=4 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[4]>Array[5] Inside the IF it SWAPS the values of the array < 3 ok New Array: This loops for j>=st, which means j >= 0. Step 11: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=7, st=0, j=3 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array > 1 swap New Array: This loops for j>=st, which means j >= 0. SAME STEPS FOR J >= ST public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 33

34 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 At Step14 both FOR loops are completed. So it checks the WHILE statement again. Then it adds 1 to the st variable. So st = 1; And it subtracks 1 from the n variable. So n = 6 Steps 15-19: Start to End Direction j = st j = 1; so it starts comparing from: array[1] >4 swap >12 ok >99 ok >3 swap >10 swap And stop after 5 loops because j must be < than n so j < 6 new temp array: NEXT 2 PAGES STEP WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 34

35 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 15: From Start To End. We are in 1 st FOR loop with n=6, st=1, j=1 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[1]>Array[2] Inside the IF it SWAPS the values of the array >4 swap j++; New Array: This loops for j<n, which means j < 6. Step 16: From Start To End. We are in 1 st FOR loop with n=6, st=1, j=2 On the IF we COMPARES the elements of the array in couples.the current and the next one. Array[2]>Array[3] Inside the IF it SWAPS the values of the array <12 ok j++; New Array: This loops for j<n, which means j < 6. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 35

36 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 17: From Start To End. We are in 1 st FOR loop with n=6, st=1, j=3 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array <99 ok j++; New Array: This loops for j<n, which means j < 6. Step 18: From Start To End. We are in 1 st FOR loop with n=6, st=1, j=4 On the IF we COMPARES the elements of the array in couples.the current and the next one. Array[4]>Array[5] Inside the IF it SWAPS the values of the array >3 swap j++; New Array: This loops for j<n, which means j < 6. SAME STEPS FOR J < N public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 36

37 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 st = 1; n = 6 First subtrack 1 from j then check if j >= st So, the starting value of j (j = n) will NOT be 6 but 5. Steps 20-24: End to Start Direction j=n j 6 but j j=5; so it starts comparing from array[5] > array[6] <99 ok j = <10 ok j = >3 swap j = >3 swap j = >3 swap j = 1 And stops after 5 loops because j >= st; j >= 1; new array = NEXT 2 PAGES STEP WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 37

38 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 20: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=6, st=1, j=5 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[5]>Array[6] Inside the IF it SWAPS the values of the array <99 ok j++; New Array: This loops for j>=st, which means j >= 1. Step 21: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=6, st=1, j=4 On the IF we COMPARES the elements of the array in couples.the current and the next one. Array[4]>Array[5] Inside the IF it SWAPS the values of the array <10 ok j++; New Array: This loops for j>=st, which means j >= 1. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 38

39 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 22: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=6, st=1, j=3 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array >3 swap j++; New Array: This loops for j>=st, which means j >= 1. Step 23: From End To Start. Here it first decreases the j and then enters the loop.(--j) We are in 2 st FOR loop with n=6, st=1, j=2 On the IF we COMPARES the elements of the array in couples.the current and the next one. Array[2]>Array[3] Inside the IF it SWAPS the values of the array >3 swap j++; New Array: This loops for j>=st, which means j >= 1. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 39

40 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 At Step24 both FOR loops are completed again. So it checks the WHILE statement once more. Then it adds 1 to the st variable. So st = 2; And it subtracks 1 from the n variable. So n = 5 Steps 25-27: Start to End Direction j = st => j = 2; so it starts comparing from: array[2] <9 ok <12 ok >10 swap And stop after 3 loops because j must be < than n so j < 5 new temp array: NEXT 2 PAGES STEP WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 40

41 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 25: From Start To End. We are in 1 st FOR loop with n=5, st=2, j=2 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[2]>Array[3] Inside the IF it SWAPS the values of the array <9 ok j++; New Array: This loops for j<n, which means j < 5. Step 26: From Start To End. We are in 1 st FOR loop with n=5, st=2, j=3 On the IF we COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array <12 ok j++; New Array: This loops for j<n, which means j < 5. public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 41

42 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 Step 27: From Start To End. We are in 1 st FOR loop with n=5, st=2, j=4 On the IF it COMPARES the elements of the array in couples.the current and the next one. Array[3]>Array[4] Inside the IF it SWAPS the values of the array >10 swap j++; New Array: This loops for j<n, which means j < 5. SAME STEPS FOR J < N public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 42

43 Bubble Sort Working of bubble sort algorithm Example Array Elements: Start Order = 12, 9, 4, 99, 120, 1, 3, 10 st = 2; n = 5; First subtrack 1 from j then check if j >= st So, the starting value of j (j = n) will NOT be 5 but 4. Steps 28-30: End to Start Direction <12 ok <10 ok <9 ok new array = NEXT PAGE STEP WITH DETAILES public static void bidirectionalbubble_srt(int array[], int n){ int j; int st = -1; while (st < n) { st++; n--; for (j = st; j < n; j++) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; for (j = n; --j >= st;) { if (array[j] > array[j + 1]) { int T = array[j]; array[j] = array[j + 1]; array[j + 1] = T; Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 43

44 Quick Sort Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 44

45 Quick sort Introduction Quick sort algorithm is developed by C. A. R. Hoare. Quick sort is a comparison sort. The working of quick sort algorithm is depending on a divide-and-conquer strategy. A divide and conquer strategy is dividing an array into two sub-arrays. Quick sort is one of the fastest and simplest sorting algorithm. The complexity of quick sort in the average case is Θ(n log(n)) and in the worst case is Θ(n2). Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 45

46 Quick sort Code description In quick sort algorithm pick an element from array of elements. This element is called the pivot. Then compare the values from left to right until a greater element is find then swap the values. Again start comparison from right with pivot. When lesser element is find then swap the values. Follow the same steps until all elements which are less than the pivot come before the pivot and all elements greater than the pivot come after it. After this partitioning, the pivot is in its last position.this is called the partition operation. Recursively sort the sub-array of lesser elements and the sub-array of greater elements. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 46

47 Quick sort Algorithm description The divide-and-conquer strategy is used in quick-sort. Below the recursion step is described: Choose a pivot value. We take the value of the middle element as pivot value, but it can be any value, which is in range of sorted values, even if it doesn't present in the array. Partition. Rearrange elements in such a way, that all elements which are lesser than the pivot go to the left part of the array and all elements greater than the pivot, go to the right part of the array. Values equal to the pivot can stay in any part of the array. Notice, that array may be divided in non-equal parts. Sort both parts. Apply quick-sort algorithm recursively to the left and the right parts. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 47

48 Quick sort Partition algorithm in detail There are two indices i and j and at the very beginning of the partition algorithm i points to the first element in the array and j points to the last one. Then algorithm moves i forward, until an element with value greater or equal to the pivot is found. Index j is moved backward, until an element with value lesser or equal to the pivot is found. If i j then they are swapped and i steps to the next position (i + 1), j steps to the previous one (j - 1). Algorithm stops, when i becomes greater than j. After partition, all values before i-th element are less or equal than the pivot and all values after j-th element are greater or equal to the pivot. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 48

49 Quick Sort An example Example. Sort {1, 12, 5, 26, 7, 14, 3, 7, 2 using quicksort. Notice, that we show here only the first recursion step, in order not to make example too long. But, in fact, {1, 2, 5, 7, 3 and {14, 7, 26, 12 are sorted then recursively. Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 49

50 Quick Sort Working of quick sort algorithm Example Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 50

51 Quick Sort Working of quick sort algorithm Example Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 51

52 Quick Sort Working of quick sort algorithm Example Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 52

53 Quick Sort Example code1 public class QuickSort{ public static void main(string a[]){ int i; int array[] = {12,9,4,99,120,1,3,10,13; System.out.println("\n\n RoseIndia\n\n"); System.out.println(" Quick Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); quick_srt(array,0,array.length-1); System.out.print("Values after the sort:\n"); for(i = 0; i <array.length; i++) System.out.print(array[i]+" "); System.out.println(); System.out.println("PAUSE"); public static void quick_srt(int array[],int low, int n){ int lo = low; int hi = n; if (lo >= n) { return; int mid = array[(lo + hi) / 2]; while (lo < hi) { while (lo<hi && array[lo] < mid) { lo++; while (lo<hi && array[hi] > mid) { hi--; if (lo < hi) { int T = array[lo]; array[lo] = array[hi]; array[hi] = T; if (hi < lo) { int T = hi; hi = lo; lo = T; quick_srt(array, low, lo); quick_srt(array, lo == low? lo+1 : lo, n); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 53

54 Quick Sort Example code_2 public class QuickSort{ public static void main(string a[]){ int i; int array[] = {12,9,4,99,120,1,3,10,13; System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); quick_srt(array,0,array.length-1); System.out.print("Values after the sort:\n"); for(i = 0; i <array.length; i++) System.out.print(array[i]+" "); System.out.println(); System.out.println("PAUSE"); public static void quick_srt(int array[],int low, int high){ int lq = low; int hq = high; int mid, temp; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; if(lq <= hq){ temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); if(low < hq) quick_srt(array, low, hq); if(lq < high) quick_srt(array, lq, high); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 54

55 Step By Step Analisys(Theory) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 It originates values of low and high into the others because we are going to use it again so we need them stored somewhere. It also assigns to mid the value stored into the array we need to be our pivot. Now we enter the do loop and the firtst while loop. Here it checks whether the array[lq] is smaller than mid. While this is true it adds 1 to the lq variable. When the first while loop ends, it enters the second: Here it checks whether the mid is smaller than the array[hq]. While this is true it subtracks 1 from the hq variable. In both of the while loops is where COMPARISONS take place. In this 1 st if statement, the SWAPS are done. All the above run while the do-while loop is true. (lq < = hq) Now we come to the last two if statements. On the 2 nd if it checks if low, the one we had from the beginnig(low = 0) is smaller than the hq the one that changed through the quick(). If its true it calls itself with array, low, hq as definitions. Same thing will happen on the 3 rd if but with different variables for the definition. If none of the two if is true it ends the quick algorithm and returns to main. public static void quick(int array[],int low, int high){ int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; if(lq <= hq){ temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(loq <= hq); if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); 1 st While 2 nd While Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 55 1 st If 2 nd if 3 rd if

56 Step By Step Analisys(Variables) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 VALUES FOR FISRT RUN OF quick() array[] = {12,9,4,99,120,1,3,10,13, low = 0, high = 8 because (array.length 1); lq = 0; hq = 8; mid = array[ ( 0+8) / 2] = array[4] = 120; array[0] = 12, mid = < 120 true lq++; array[1] = 9, mid = < 120 true lq++; array[2] = 4, mid = < 120 true lq++; array[3] = 99, mid = < 120 true lq++; array[4] = 120,mid = < 120 false (lq=4) array[8] = 13,mid = < 13 false (hq=8) lq = 4,hq = 8 4 < = 8 true temp = array[4]; temp = 120 array[4] = array[8]; array[4] = 13 array[8] = temp; array[8] = 120 lq++; lq = 5 hq--; hq = 7 new array: {12, 9, 4, 99, 13, 1, 3, 10, 120; lq = 5, hq = 7 5 < = 7 true run again public static void quick(int array[],int low, int high){ int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; Runs 4 times Runs 0 times if(lq <= hq){ Enters temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); It s true and runs again if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 56

57 Step By Step Analisys(Variables) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 public static void quick(int array[],int low, int high){ Having from previous: lq = 5; hq = 7; mid = 120 array[ ] = {12, 9, 4, 99, 13, 1, 3, 10, 120; array[5] = 1, mid = < 120 true lq++; array[6] = 3, mid = < 120 true lq++; array[7] = 10, mid = < 120 true lq++; array[8] = 120, mid = < 120 false ---- (lq=8) array[7] = 10, mid = < 10 false --- (hq = 7) int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; Runs 3 times Runs 0 times lq = 8, hq = 7 8 <= 7 false new array: {12, 9, 4, 99, 13, 1, 3, 10, 120; same as before lq = 8, hq = 7 8 < = 7 false low = 0, hq = 7 0 < 7 true array[ ] = {12, 9, 4, 99, 13, 1, 3, 10, 120, low = 0, hq = 7; Now it transfers these values and the array back to the top of the algorithm. So at the next step we ll see how it s done. if(lq <= hq){ Doesn t Enter temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); Has run 2 times if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 57

58 Step By Step Analisys(Variables) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 VALUES FOR SECOND RUN OF quick() new array: {12, 9, 4, 99, 13, 1, 3, 10, 120, low = 0, high = 7 because the values are transferred from the previous run of quick() when we called quick(array, low, hq); lq = 0; hq = 7; mid = array[ ( 0+7) / 2] = array[4] = 13; array[0] = 12, mid = < 13 true lq++; array[1] = 9, mid = 13 9 < 13 true lq++; array[2] = 4, mid = 13 4 < 13 true lq++; array[3] = 99, mid = < 13 false ---- (lq = 3) public static void quick(int array[],int low, int high){ int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; Runs 3 times Runs 0 times array[7] = 10, mid = < 10 false ---- (hq = 7) lq = 3, hq = 7 3 <= 7 true temp = array[3]; temp = 99 array[3] = array[7]; array[3] = 10 array[7] = temp; array[7] = 99 lq++; lq = 4 hg--; hq = 6 new array: {12, 9, 4, 10, 13, 1, 3, 99, 120; if(lq <= hq){ Enters temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); It s true and runs again lq = 4, hq = 6 4 < = 6 true run again if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 58

59 Step By Step Analisys(Variables) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 public static void quick(int array[],int low, int high){ Having from previous: lq = 4; hq = 6; mid = 13 array[ ] = {12, 9, 4, 10, 13, 1, 3, 99, 120; array[4] = 13, mid = < 13 false ---- (lq = 4) array[6] = 3, mid = < 3 false ----(hq = 6) int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; Runs 0 times Runs 0 times lq = 4, hq = 6 4 <= 6 true temp = array[4]; temp = 13 array[4] = array[6]; array[4] = 3 array[6] = temp; array[6] = 13 lq++; lq = 5 hq--; hq = 5 new array: {12, 9, 4, 10, 3, 1, 13, 99, 120; lq = 5, hq = 5 5 < = 5 true run again if(lq <= hq){ Enters temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); It s true and runs again if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 59

60 Step By Step Analisys(Variables) Array Elements: Start Order = 12,9,4,99,120,1,3,10,13 public static void quick(int array[],int low, int high){ Having from previous: lq = 5; hq = 5; mid = 13 array[ ] = {12, 9, 4, 10, 3, 1, 13, 99, 120; array[5] = 1, mid = 13 1 < 13 true lq++; array[6] = 13, mid = < 13 false (lq = 6) array[5] = 1, mid = < 1 false ---- (hq = 5) lq = 6, hq = 5 6 <= 5 false new array: {12, 9, 4, 10, 3, 1, 13, 99, 120; same as before lq = 6, hq = 5 6 < = 5 false low = 0, hq = 5 0 < 5 true array[ ] = {12, 9, 4, 10, 3, 1, 13, 99, 120, low = 0, hq = 5; Now it transfers these values and the array back to the top of the algorithm. So at the next step we ll see how it s done. int mid, temp; int lq = low; int hq = high; mid = array[(low + high)/2]; do{ while(array[lq] < mid) lq++; while(mid < array[hq]) hq--; if(lq <= hq){ temp = array[lq]; array[lq] = array[hq]; array[hq] = temp; lq++; hq--; while(lq <= hq); if(low < hq) quick(array, low, hq); if(lq < high) quick(array, lq, high); Runs 1 time Runs 0 times Doesn t Enters Has run 3 times Μάθημα: Δομές Δεδομένων & Αλγόριθμοι (Εργαστήριο) Καθηγητής: Δρ. Βιδάκης Νίκος Slide 60

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ Κωδικός Θ: ΤΠ3001, Κωδικός Ε: ΤΠ3101 (ΜΕΥ/Υ) Ώρες (Θ - Ε): 4-2 Προαπαιτούμενα: Δρ. ΒΙΔΑΚΗΣ ΝΙΚΟΣ ΕΡΓΑΣΤΗΡΙΟ 5 Ταξινόμηση με 1. Insertion Sort 2. Selection Sort Insertion

Διαβάστε περισσότερα

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β 3.4 SUM AND DIFFERENCE FORMULAS Page Theorem cos(αβ cos α cos β -sin α cos(α-β cos α cos β sin α NOTE: cos(αβ cos α cos β cos(α-β cos α -cos β Proof of cos(α-β cos α cos β sin α Let s use a unit circle

Διαβάστε περισσότερα

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch: HOMEWORK 4 Problem a For the fast loading case, we want to derive the relationship between P zz and λ z. We know that the nominal stress is expressed as: P zz = ψ λ z where λ z = λ λ z. Therefore, applying

Διαβάστε περισσότερα

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required) Phys460.nb 81 ψ n (t) is still the (same) eigenstate of H But for tdependent H. The answer is NO. 5.5.5. Solution for the tdependent Schrodinger s equation If we assume that at time t 0, the electron starts

Διαβάστε περισσότερα

2 Composition. Invertible Mappings

2 Composition. Invertible Mappings Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan Composition. Invertible Mappings In this section we discuss two procedures for creating new mappings from old ones, namely,

Διαβάστε περισσότερα

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS CHAPTER 5 SOLVING EQUATIONS BY ITERATIVE METHODS EXERCISE 104 Page 8 1. Find the positive root of the equation x + 3x 5 = 0, correct to 3 significant figures, using the method of bisection. Let f(x) =

Διαβάστε περισσότερα

Section 8.3 Trigonometric Equations

Section 8.3 Trigonometric Equations 99 Section 8. Trigonometric Equations Objective 1: Solve Equations Involving One Trigonometric Function. In this section and the next, we will exple how to solving equations involving trigonometric functions.

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Αν κάπου κάνετε κάποιες υποθέσεις να αναφερθούν στη σχετική ερώτηση. Όλα τα αρχεία που αναφέρονται στα προβλήματα βρίσκονται στον ίδιο φάκελο με το εκτελέσιμο

Διαβάστε περισσότερα

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr 9.9 #. Area inside the oval limaçon r = + cos. To graph, start with = so r =. Compute d = sin. Interesting points are where d vanishes, or at =,,, etc. For these values of we compute r:,,, and the values

Διαβάστε περισσότερα

EE512: Error Control Coding

EE512: Error Control Coding EE512: Error Control Coding Solution for Assignment on Finite Fields February 16, 2007 1. (a) Addition and Multiplication tables for GF (5) and GF (7) are shown in Tables 1 and 2. + 0 1 2 3 4 0 0 1 2 3

Διαβάστε περισσότερα

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ Κωδικός Θ: ΤΠ3001, Κωδικός Ε: ΤΠ3101 (ΜΕΥ/Υ) Ώρες (Θ - Ε): 4-2 Προαπαιτούμενα: Δρ. ΒΙΔΑΚΗΣ ΝΙΚΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Sequential & Binary Search Σειριακή & Δυαδική Αναζήτηση

Διαβάστε περισσότερα

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible. B-Trees Index files can become quite large for large main files Indices on index files are possible 3 rd -level index 2 nd -level index 1 st -level index Main file 1 The 1 st -level index consists of pairs

Διαβάστε περισσότερα

Capacitors - Capacitance, Charge and Potential Difference

Capacitors - Capacitance, Charge and Potential Difference Capacitors - Capacitance, Charge and Potential Difference Capacitors store electric charge. This ability to store electric charge is known as capacitance. A simple capacitor consists of 2 parallel metal

Διαβάστε περισσότερα

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ Κωδικός Θ: ΤΠ3001, Κωδικός Ε: ΤΠ3101 (ΜΕΥ/Υ) Ώρες (Θ - Ε): 4-2 Προαπαιτούμενα: Δρ. ΒΙΔΑΚΗΣ ΝΙΚΟΣ ΕΡΓΑΣΤΗΡΙΟ 6 Στοίβα (Stack) Stack Introduction Stack is one of the

Διαβάστε περισσότερα

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Συστήματα Διαχείρισης Βάσεων Δεδομένων ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Συστήματα Διαχείρισης Βάσεων Δεδομένων Φροντιστήριο 9: Transactions - part 1 Δημήτρης Πλεξουσάκης Τμήμα Επιστήμης Υπολογιστών Tutorial on Undo, Redo and Undo/Redo

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Ολοι οι αριθμοί που αναφέρονται σε όλα τα ερωτήματα είναι μικρότεροι το 1000 εκτός αν ορίζεται διαφορετικά στη διατύπωση του προβλήματος. Διάρκεια: 3,5 ώρες Καλή

Διαβάστε περισσότερα

Section 7.6 Double and Half Angle Formulas

Section 7.6 Double and Half Angle Formulas 09 Section 7. Double and Half Angle Fmulas To derive the double-angles fmulas, we will use the sum of two angles fmulas that we developed in the last section. We will let α θ and β θ: cos(θ) cos(θ + θ)

Διαβάστε περισσότερα

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in : tail in X, head in A nowhere-zero Γ-flow is a Γ-circulation such that

Διαβάστε περισσότερα

The Simply Typed Lambda Calculus

The Simply Typed Lambda Calculus Type Inference Instead of writing type annotations, can we use an algorithm to infer what the type annotations should be? That depends on the type system. For simple type systems the answer is yes, and

Διαβάστε περισσότερα

C.S. 430 Assignment 6, Sample Solutions

C.S. 430 Assignment 6, Sample Solutions C.S. 430 Assignment 6, Sample Solutions Paul Liu November 15, 2007 Note that these are sample solutions only; in many cases there were many acceptable answers. 1 Reynolds Problem 10.1 1.1 Normal-order

Διαβάστε περισσότερα

derivation of the Laplacian from rectangular to spherical coordinates

derivation of the Laplacian from rectangular to spherical coordinates derivation of the Laplacian from rectangular to spherical coordinates swapnizzle 03-03- :5:43 We begin by recognizing the familiar conversion from rectangular to spherical coordinates (note that φ is used

Διαβάστε περισσότερα

[1] P Q. Fig. 3.1

[1] P Q. Fig. 3.1 1 (a) Define resistance....... [1] (b) The smallest conductor within a computer processing chip can be represented as a rectangular block that is one atom high, four atoms wide and twenty atoms long. One

Διαβάστε περισσότερα

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων Εξάμηνο 7 ο Procedures and Functions Stored procedures and functions are named blocks of code that enable you to group and organize a series of SQL and PL/SQL

Διαβάστε περισσότερα

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής Να γραφεί πρόγραμμα το οποίο δέχεται ως είσοδο μια ακολουθία S από n (n 40) ακέραιους αριθμούς και επιστρέφει ως έξοδο δύο ακολουθίες από θετικούς ακέραιους

Διαβάστε περισσότερα

Math221: HW# 1 solutions

Math221: HW# 1 solutions Math: HW# solutions Andy Royston October, 5 7.5.7, 3 rd Ed. We have a n = b n = a = fxdx = xdx =, x cos nxdx = x sin nx n sin nxdx n = cos nx n = n n, x sin nxdx = x cos nx n + cos nxdx n cos n = + sin

Διαβάστε περισσότερα

Finite Field Problems: Solutions

Finite Field Problems: Solutions Finite Field Problems: Solutions 1. Let f = x 2 +1 Z 11 [x] and let F = Z 11 [x]/(f), a field. Let Solution: F =11 2 = 121, so F = 121 1 = 120. The possible orders are the divisors of 120. Solution: The

Διαβάστε περισσότερα

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0. DESIGN OF MACHINERY SOLUTION MANUAL -7-1! PROBLEM -7 Statement: Design a double-dwell cam to move a follower from to 25 6, dwell for 12, fall 25 and dwell for the remader The total cycle must take 4 sec

Διαβάστε περισσότερα

Srednicki Chapter 55

Srednicki Chapter 55 Srednicki Chapter 55 QFT Problems & Solutions A. George August 3, 03 Srednicki 55.. Use equations 55.3-55.0 and A i, A j ] = Π i, Π j ] = 0 (at equal times) to verify equations 55.-55.3. This is our third

Διαβάστε περισσότερα

Προαπαιτούμενες Ασκήσεις 5 ου Εργαστηρίου. Dose stoixeio (integer) : 25 Found stoixeio in position 7 Dose stoixeio (integer) :94 Value not found

Προαπαιτούμενες Ασκήσεις 5 ου Εργαστηρίου. Dose stoixeio (integer) : 25 Found stoixeio in position 7 Dose stoixeio (integer) :94 Value not found Α. Πρώτη προαπαιτούµενη Κάθε οµάδα θα πρέπει να δηµιουργήσει τον ζητούµενο παρακάτω πίνακα και α. να εµφανίσει τα στοιχεία του, β. να τυπώσει τον µέσο όρο των στοιχείων του, γ. να ταξινοµήσει τα στοιχεία

Διαβάστε περισσότερα

Homework 3 Solutions

Homework 3 Solutions Homework 3 Solutions Igor Yanovsky (Math 151A TA) Problem 1: Compute the absolute error and relative error in approximations of p by p. (Use calculator!) a) p π, p 22/7; b) p π, p 3.141. Solution: For

Διαβάστε περισσότερα

Σημειώσεις δεύτερης εβδομάδας

Σημειώσεις δεύτερης εβδομάδας Σημειώσεις δεύτερης εβδομάδας 1. Δυαδική αναζήτηση: /* BINARY SEARCH */ /* use sorted input */ #include int main() { int c, first, last, middle, n, search, array[100]; printf("enter number of

Διαβάστε περισσότερα

the total number of electrons passing through the lamp.

the total number of electrons passing through the lamp. 1. A 12 V 36 W lamp is lit to normal brightness using a 12 V car battery of negligible internal resistance. The lamp is switched on for one hour (3600 s). For the time of 1 hour, calculate (i) the energy

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011 Διάρκεια Διαγωνισμού: 3 ώρες Απαντήστε όλες τις ερωτήσεις Μέγιστο Βάρος (20 Μονάδες) Δίνεται ένα σύνολο από N σφαιρίδια τα οποία δεν έχουν όλα το ίδιο βάρος μεταξύ τους και ένα κουτί που αντέχει μέχρι

Διαβάστε περισσότερα

Areas and Lengths in Polar Coordinates

Areas and Lengths in Polar Coordinates Kiryl Tsishchanka Areas and Lengths in Polar Coordinates In this section we develop the formula for the area of a region whose boundary is given by a polar equation. We need to use the formula for the

Διαβάστε περισσότερα

The challenges of non-stable predicates

The challenges of non-stable predicates The challenges of non-stable predicates Consider a non-stable predicate Φ encoding, say, a safety property. We want to determine whether Φ holds for our program. The challenges of non-stable predicates

Διαβάστε περισσότερα

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι She selects the option. Jenny starts with the al listing. This has employees listed within She drills down through the employee. The inferred ER sttricture relates this to the redcords in the databasee

Διαβάστε περισσότερα

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Right Rear Door. Let's now finish the door hinge saga with the right rear door Right Rear Door Let's now finish the door hinge saga with the right rear door You may have been already guessed my steps, so there is not much to describe in detail. Old upper one file:///c /Documents

Διαβάστε περισσότερα

Areas and Lengths in Polar Coordinates

Areas and Lengths in Polar Coordinates Kiryl Tsishchanka Areas and Lengths in Polar Coordinates In this section we develop the formula for the area of a region whose boundary is given by a polar equation. We need to use the formula for the

Διαβάστε περισσότερα

Example Sheet 3 Solutions

Example Sheet 3 Solutions Example Sheet 3 Solutions. i Regular Sturm-Liouville. ii Singular Sturm-Liouville mixed boundary conditions. iii Not Sturm-Liouville ODE is not in Sturm-Liouville form. iv Regular Sturm-Liouville note

Διαβάστε περισσότερα

Approximation of distance between locations on earth given by latitude and longitude

Approximation of distance between locations on earth given by latitude and longitude Approximation of distance between locations on earth given by latitude and longitude Jan Behrens 2012-12-31 In this paper we shall provide a method to approximate distances between two points on earth

Διαβάστε περισσότερα

Concrete Mathematics Exercises from 30 September 2016

Concrete Mathematics Exercises from 30 September 2016 Concrete Mathematics Exercises from 30 September 2016 Silvio Capobianco Exercise 1.7 Let H(n) = J(n + 1) J(n). Equation (1.8) tells us that H(2n) = 2, and H(2n+1) = J(2n+2) J(2n+1) = (2J(n+1) 1) (2J(n)+1)

Διαβάστε περισσότερα

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =? Teko Classes IITJEE/AIEEE Maths by SUHAAG SIR, Bhopal, Ph (0755) 3 00 000 www.tekoclasses.com ANSWERSHEET (TOPIC DIFFERENTIAL CALCULUS) COLLECTION # Question Type A.Single Correct Type Q. (A) Sol least

Διαβάστε περισσότερα

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ Κωδικός Θ: ΤΠ3001, Κωδικός Ε: ΤΠ3101 (ΜΕΥ/Υ) Ώρες (Θ - Ε): 4-2 Προαπαιτούμενα: Δρ. ΒΙΔΑΚΗΣ ΝΙΚΟΣ ΕΡΓΑΣΤΗΡΙΟ 7 Ουρά (Queue) Queue Μάθημα: Δομές Δεδομένων & Αλγόριθμοι

Διαβάστε περισσότερα

ST5224: Advanced Statistical Theory II

ST5224: Advanced Statistical Theory II ST5224: Advanced Statistical Theory II 2014/2015: Semester II Tutorial 7 1. Let X be a sample from a population P and consider testing hypotheses H 0 : P = P 0 versus H 1 : P = P 1, where P j is a known

Διαβάστε περισσότερα

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ. Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο The time integral of a force is referred to as impulse, is determined by and is obtained from: Newton s 2 nd Law of motion states that the action

Διαβάστε περισσότερα

Instruction Execution Times

Instruction Execution Times 1 C Execution Times InThisAppendix... Introduction DL330 Execution Times DL330P Execution Times DL340 Execution Times C-2 Execution Times Introduction Data Registers This appendix contains several tables

Διαβάστε περισσότερα

Math 6 SL Probability Distributions Practice Test Mark Scheme

Math 6 SL Probability Distributions Practice Test Mark Scheme Math 6 SL Probability Distributions Practice Test Mark Scheme. (a) Note: Award A for vertical line to right of mean, A for shading to right of their vertical line. AA N (b) evidence of recognizing symmetry

Διαβάστε περισσότερα

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook Βήμα 1: Step 1: Βρείτε το βιβλίο που θα θέλατε να αγοράσετε και πατήστε Add to Cart, για να το προσθέσετε στο καλάθι σας. Αυτόματα θα

Διαβάστε περισσότερα

4.6 Autoregressive Moving Average Model ARMA(1,1)

4.6 Autoregressive Moving Average Model ARMA(1,1) 84 CHAPTER 4. STATIONARY TS MODELS 4.6 Autoregressive Moving Average Model ARMA(,) This section is an introduction to a wide class of models ARMA(p,q) which we will consider in more detail later in this

Διαβάστε περισσότερα

Μηχανική Μάθηση Hypothesis Testing

Μηχανική Μάθηση Hypothesis Testing ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Μηχανική Μάθηση Hypothesis Testing Γιώργος Μπορμπουδάκης Τμήμα Επιστήμης Υπολογιστών Procedure 1. Form the null (H 0 ) and alternative (H 1 ) hypothesis 2. Consider

Διαβάστε περισσότερα

Example of the Baum-Welch Algorithm

Example of the Baum-Welch Algorithm Example of the Baum-Welch Algorithm Larry Moss Q520, Spring 2008 1 Our corpus c We start with a very simple corpus. We take the set Y of unanalyzed words to be {ABBA, BAB}, and c to be given by c(abba)

Διαβάστε περισσότερα

Every set of first-order formulas is equivalent to an independent set

Every set of first-order formulas is equivalent to an independent set Every set of first-order formulas is equivalent to an independent set May 6, 2008 Abstract A set of first-order formulas, whatever the cardinality of the set of symbols, is equivalent to an independent

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Όλοι οι αριθμοί που αναφέρονται σε όλα τα ερωτήματα μικρότεροι του 10000 εκτός αν ορίζεται διαφορετικά στη διατύπωση του προβλήματος. Αν κάπου κάνετε κάποιες υποθέσεις

Διαβάστε περισσότερα

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω 0 1 2 3 4 5 6 ω ω + 1 ω + 2 ω + 3 ω + 4 ω2 ω2 + 1 ω2 + 2 ω2 + 3 ω3 ω3 + 1 ω3 + 2 ω4 ω4 + 1 ω5 ω 2 ω 2 + 1 ω 2 + 2 ω 2 + ω ω 2 + ω + 1 ω 2 + ω2 ω 2 2 ω 2 2 + 1 ω 2 2 + ω ω 2 3 ω 3 ω 3 + 1 ω 3 + ω ω 3 +

Διαβάστε περισσότερα

Solutions to Exercise Sheet 5

Solutions to Exercise Sheet 5 Solutions to Eercise Sheet 5 jacques@ucsd.edu. Let X and Y be random variables with joint pdf f(, y) = 3y( + y) where and y. Determine each of the following probabilities. Solutions. a. P (X ). b. P (X

Διαβάστε περισσότερα

Pg The perimeter is P = 3x The area of a triangle is. where b is the base, h is the height. In our case b = x, then the area is

Pg The perimeter is P = 3x The area of a triangle is. where b is the base, h is the height. In our case b = x, then the area is Pg. 9. The perimeter is P = The area of a triangle is A = bh where b is the base, h is the height 0 h= btan 60 = b = b In our case b =, then the area is A = = 0. By Pythagorean theorem a + a = d a a =

Διαβάστε περισσότερα

Code Breaker. TEACHER s NOTES

Code Breaker. TEACHER s NOTES TEACHER s NOTES Time: 50 minutes Learning Outcomes: To relate the genetic code to the assembly of proteins To summarize factors that lead to different types of mutations To distinguish among positive,

Διαβάστε περισσότερα

Section 9.2 Polar Equations and Graphs

Section 9.2 Polar Equations and Graphs 180 Section 9. Polar Equations and Graphs In this section, we will be graphing polar equations on a polar grid. In the first few examples, we will write the polar equation in rectangular form to help identify

Διαβάστε περισσότερα

Bounding Nonsplitting Enumeration Degrees

Bounding Nonsplitting Enumeration Degrees Bounding Nonsplitting Enumeration Degrees Thomas F. Kent Andrea Sorbi Università degli Studi di Siena Italia July 18, 2007 Goal: Introduce a form of Σ 0 2-permitting for the enumeration degrees. Till now,

Διαβάστε περισσότερα

Lecture 2. Soundness and completeness of propositional logic

Lecture 2. Soundness and completeness of propositional logic Lecture 2 Soundness and completeness of propositional logic February 9, 2004 1 Overview Review of natural deduction. Soundness and completeness. Semantics of propositional formulas. Soundness proof. Completeness

Διαβάστε περισσότερα

Tridiagonal matrices. Gérard MEURANT. October, 2008

Tridiagonal matrices. Gérard MEURANT. October, 2008 Tridiagonal matrices Gérard MEURANT October, 2008 1 Similarity 2 Cholesy factorizations 3 Eigenvalues 4 Inverse Similarity Let α 1 ω 1 β 1 α 2 ω 2 T =......... β 2 α 1 ω 1 β 1 α and β i ω i, i = 1,...,

Διαβάστε περισσότερα

Partial Trace and Partial Transpose

Partial Trace and Partial Transpose Partial Trace and Partial Transpose by José Luis Gómez-Muñoz http://homepage.cem.itesm.mx/lgomez/quantum/ jose.luis.gomez@itesm.mx This document is based on suggestions by Anirban Das Introduction This

Διαβάστε περισσότερα

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Main source: Discrete-time systems and computer control by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1 Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1 A Brief History of Sampling Research 1915 - Edmund Taylor Whittaker (1873-1956) devised a

Διαβάστε περισσότερα

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS EXERCISE 01 Page 545 1. Use matrices to solve: 3x + 4y x + 5y + 7 3x + 4y x + 5y 7 Hence, 3 4 x 0 5 y 7 The inverse of 3 4 5 is: 1 5 4 1 5 4 15 8 3

Διαβάστε περισσότερα

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions SCHOOL OF MATHEMATICAL SCIENCES GLMA Linear Mathematics 00- Examination Solutions. (a) i. ( + 5i)( i) = (6 + 5) + (5 )i = + i. Real part is, imaginary part is. (b) ii. + 5i i ( + 5i)( + i) = ( i)( + i)

Διαβάστε περισσότερα

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation Overview Transition Semantics Configurations and the transition relation Executions and computation Inference rules for small-step structural operational semantics for the simple imperative language Transition

Διαβάστε περισσότερα

TMA4115 Matematikk 3

TMA4115 Matematikk 3 TMA4115 Matematikk 3 Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet Trondheim Spring 2010 Lecture 12: Mathematics Marvellous Matrices Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet

Διαβάστε περισσότερα

Second Order RLC Filters

Second Order RLC Filters ECEN 60 Circuits/Electronics Spring 007-0-07 P. Mathys Second Order RLC Filters RLC Lowpass Filter A passive RLC lowpass filter (LPF) circuit is shown in the following schematic. R L C v O (t) Using phasor

Διαβάστε περισσότερα

5.4 The Poisson Distribution.

5.4 The Poisson Distribution. The worst thing you can do about a situation is nothing. Sr. O Shea Jackson 5.4 The Poisson Distribution. Description of the Poisson Distribution Discrete probability distribution. The random variable

Διαβάστε περισσότερα

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Ψηφιακή Οικονομία Διάλεξη 0η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών Best Response Curves Used to solve for equilibria in games

Διαβάστε περισσότερα

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds! MTH U341 urface Integrals, tokes theorem, the divergence theorem To be turned in Wed., Dec. 1. 1. Let be the sphere of radius a, x 2 + y 2 + z 2 a 2. a. Use spherical coordinates (with ρ a) to parametrize.

Διαβάστε περισσότερα

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά. Διαστημικό εστιατόριο του (Μ)ΑστροΈκτορα Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά. Μόλις μια παρέα πελατών κάτσει σε ένα

Διαβάστε περισσότερα

Fractional Colorings and Zykov Products of graphs

Fractional Colorings and Zykov Products of graphs Fractional Colorings and Zykov Products of graphs Who? Nichole Schimanski When? July 27, 2011 Graphs A graph, G, consists of a vertex set, V (G), and an edge set, E(G). V (G) is any finite set E(G) is

Διαβάστε περισσότερα

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit Ting Zhang Stanford May 11, 2001 Stanford, 5/11/2001 1 Outline Ordinal Classification Ordinal Addition Ordinal Multiplication Ordinal

Διαβάστε περισσότερα

forms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with

forms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with Week 03: C lassification of S econd- Order L inear Equations In last week s lectures we have illustrated how to obtain the general solutions of first order PDEs using the method of characteristics. We

Διαβάστε περισσότερα

Assalamu `alaikum wr. wb.

Assalamu `alaikum wr. wb. LUMP SUM Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. LUMP SUM Lump sum lump sum lump sum. lump sum fixed price lump sum lump

Διαβάστε περισσότερα

Modbus basic setup notes for IO-Link AL1xxx Master Block

Modbus basic setup notes for IO-Link AL1xxx Master Block n Modbus has four tables/registers where data is stored along with their associated addresses. We will be using the holding registers from address 40001 to 49999 that are R/W 16 bit/word. Two tables that

Διαβάστε περισσότερα

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ ΕΛΕΝΑ ΦΛΟΚΑ Επίκουρος Καθηγήτρια Τµήµα Φυσικής, Τοµέας Φυσικής Περιβάλλοντος- Μετεωρολογίας ΓΕΝΙΚΟΙ ΟΡΙΣΜΟΙ Πληθυσµός Σύνολο ατόµων ή αντικειµένων στα οποία αναφέρονται

Διαβάστε περισσότερα

LESSON 14 (ΜΑΘΗΜΑ ΔΕΚΑΤΕΣΣΕΡΑ) REF : 202/057/34-ADV. 18 February 2014

LESSON 14 (ΜΑΘΗΜΑ ΔΕΚΑΤΕΣΣΕΡΑ) REF : 202/057/34-ADV. 18 February 2014 LESSON 14 (ΜΑΘΗΜΑ ΔΕΚΑΤΕΣΣΕΡΑ) REF : 202/057/34-ADV 18 February 2014 Slowly/quietly Clear/clearly Clean Quickly/quick/fast Hurry (in a hurry) Driver Attention/caution/notice/care Dance Σιγά Καθαρά Καθαρός/η/ο

Διαβάστε περισσότερα

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1. Exercises 0 More exercises are available in Elementary Differential Equations. If you have a problem to solve any of them, feel free to come to office hour. Problem Find a fundamental matrix of the given

Διαβάστε περισσότερα

Durbin-Levinson recursive method

Durbin-Levinson recursive method Durbin-Levinson recursive method A recursive method for computing ϕ n is useful because it avoids inverting large matrices; when new data are acquired, one can update predictions, instead of starting again

Διαβάστε περισσότερα

On a four-dimensional hyperbolic manifold with finite volume

On a four-dimensional hyperbolic manifold with finite volume BULETINUL ACADEMIEI DE ŞTIINŢE A REPUBLICII MOLDOVA. MATEMATICA Numbers 2(72) 3(73), 2013, Pages 80 89 ISSN 1024 7696 On a four-dimensional hyperbolic manifold with finite volume I.S.Gutsul Abstract. In

Διαβάστε περισσότερα

6.3 Forecasting ARMA processes

6.3 Forecasting ARMA processes 122 CHAPTER 6. ARMA MODELS 6.3 Forecasting ARMA processes The purpose of forecasting is to predict future values of a TS based on the data collected to the present. In this section we will discuss a linear

Διαβάστε περισσότερα

Matrices and vectors. Matrix and vector. a 11 a 12 a 1n a 21 a 22 a 2n A = b 1 b 2. b m. R m n, b = = ( a ij. a m1 a m2 a mn. def

Matrices and vectors. Matrix and vector. a 11 a 12 a 1n a 21 a 22 a 2n A = b 1 b 2. b m. R m n, b = = ( a ij. a m1 a m2 a mn. def Matrices and vectors Matrix and vector a 11 a 12 a 1n a 21 a 22 a 2n A = a m1 a m2 a mn def = ( a ij ) R m n, b = b 1 b 2 b m Rm Matrix and vectors in linear equations: example E 1 : x 1 + x 2 + 3x 4 =

Διαβάστε περισσότερα

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony Ελληνικά Ι English 1/7 Δημιουργία Λογαριασμού Διαχείρισης Επιχειρηματικής Τηλεφωνίας μέσω της ιστοσελίδας

Διαβάστε περισσότερα

ΑΡΙΣΤΟΤΕΛΕΙΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΟΝΙΚΗΣ ΤΜΗΜΑ ΟΔΟΝΤΙΑΤΡΙΚΗΣ ΕΡΓΑΣΤΗΡΙΟ ΟΔΟΝΤΙΚΗΣ ΚΑΙ ΑΝΩΤΕΡΑΣ ΠΡΟΣΘΕΤΙΚΗΣ

ΑΡΙΣΤΟΤΕΛΕΙΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΟΝΙΚΗΣ ΤΜΗΜΑ ΟΔΟΝΤΙΑΤΡΙΚΗΣ ΕΡΓΑΣΤΗΡΙΟ ΟΔΟΝΤΙΚΗΣ ΚΑΙ ΑΝΩΤΕΡΑΣ ΠΡΟΣΘΕΤΙΚΗΣ ΑΡΙΣΤΟΤΕΛΕΙΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΟΝΙΚΗΣ ΤΜΗΜΑ ΟΔΟΝΤΙΑΤΡΙΚΗΣ ΕΡΓΑΣΤΗΡΙΟ ΟΔΟΝΤΙΚΗΣ ΚΑΙ ΑΝΩΤΕΡΑΣ ΠΡΟΣΘΕΤΙΚΗΣ ΣΥΓΚΡΙΤΙΚΗ ΜΕΛΕΤΗ ΤΗΣ ΣΥΓΚΡΑΤΗΤΙΚΗΣ ΙΚΑΝΟΤΗΤΑΣ ΟΡΙΣΜΕΝΩΝ ΠΡΟΚΑΤΑΣΚΕΥΑΣΜΕΝΩΝ ΣΥΝΔΕΣΜΩΝ ΑΚΡΙΒΕΙΑΣ

Διαβάστε περισσότερα

FORTRAN & Αντικειμενοστραφής Προγραμματισμός ΣΝΜΜ 2017

FORTRAN & Αντικειμενοστραφής Προγραμματισμός ΣΝΜΜ 2017 FORTRAN & Αντικειμενοστραφής Προγραμματισμός ΣΝΜΜ 2017 M7 Δομές δεδομένων: Πίνακες - Ασκήσεις Γεώργιος Παπαλάμπρου Επικ. Καθηγητής ΕΜΠ Εργαστήριο Ναυτικής Μηχανολογίας george.papalambrou@lme.ntua.gr ΕΜΠ/ΣΝΜΜ

Διαβάστε περισσότερα

Other Test Constructions: Likelihood Ratio & Bayes Tests

Other Test Constructions: Likelihood Ratio & Bayes Tests Other Test Constructions: Likelihood Ratio & Bayes Tests Side-Note: So far we have seen a few approaches for creating tests such as Neyman-Pearson Lemma ( most powerful tests of H 0 : θ = θ 0 vs H 1 :

Διαβάστε περισσότερα

D Alembert s Solution to the Wave Equation

D Alembert s Solution to the Wave Equation D Alembert s Solution to the Wave Equation MATH 467 Partial Differential Equations J. Robert Buchanan Department of Mathematics Fall 2018 Objectives In this lesson we will learn: a change of variable technique

Διαβάστε περισσότερα

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8  questions or comments to Dan Fetter 1 Eon : Fall 8 Suggested Solutions to Problem Set 8 Email questions or omments to Dan Fetter Problem. Let X be a salar with density f(x, θ) (θx + θ) [ x ] with θ. (a) Find the most powerful level α test

Διαβάστε περισσότερα

ΗΥ-150. Ταξινόµηση και Αναζήτηση

ΗΥ-150. Ταξινόµηση και Αναζήτηση ΗΥ-150 Ταξινόµηση και Αναζήτηση To πρόβληµα της Αναζήτησης οθέντος δεδοµένων, λ.χ. σε Πίνακα (P) Ψάχνω να βρω κάποιο συγκεκριµένο στοιχείο (key) Αν ο πίνακας δεν είναι ταξινοµηµένος Γραµµική Αναζήτηση

Διαβάστε περισσότερα

Problem Set 3: Solutions

Problem Set 3: Solutions CMPSCI 69GG Applied Information Theory Fall 006 Problem Set 3: Solutions. [Cover and Thomas 7.] a Define the following notation, C I p xx; Y max X; Y C I p xx; Ỹ max I X; Ỹ We would like to show that C

Διαβάστε περισσότερα

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade Για να ελέγξετε το λογισμικό που έχει τώρα η συσκευή κάντε κλικ Menu > Options > Device > About Device Versions. Στο πιο κάτω παράδειγμα η συσκευή έχει έκδοση λογισμικού 6.0.0.546 με πλατφόρμα 6.6.0.207.

Διαβάστε περισσότερα

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Ενότητα 12: Συνοπτική Παρουσίαση Ανάπτυξης Κώδικα με το Matlab Σαμαράς Νικόλαος Άδειες Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons.

Διαβάστε περισσότερα

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3) Q1. (a) A fluorescent tube is filled with mercury vapour at low pressure. In order to emit electromagnetic radiation the mercury atoms must first be excited. (i) What is meant by an excited atom? (1) (ii)

Διαβάστε περισσότερα

Advanced Subsidiary Unit 1: Understanding and Written Response

Advanced Subsidiary Unit 1: Understanding and Written Response Write your name here Surname Other names Edexcel GE entre Number andidate Number Greek dvanced Subsidiary Unit 1: Understanding and Written Response Thursday 16 May 2013 Morning Time: 2 hours 45 minutes

Διαβάστε περισσότερα

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Ψηφιακή Οικονομία Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών Τέλος Ενότητας Χρηματοδότηση Το παρόν εκπαιδευτικό υλικό έχει αναπτυχθεί

Διαβάστε περισσότερα

Inverse trigonometric functions & General Solution of Trigonometric Equations. ------------------ ----------------------------- -----------------

Inverse trigonometric functions & General Solution of Trigonometric Equations. ------------------ ----------------------------- ----------------- Inverse trigonometric functions & General Solution of Trigonometric Equations. 1. Sin ( ) = a) b) c) d) Ans b. Solution : Method 1. Ans a: 17 > 1 a) is rejected. w.k.t Sin ( sin ) = d is rejected. If sin

Διαβάστε περισσότερα

Εργαστήριο 7: Ο αλγόριθμος ταξινόμησης Radix Sort

Εργαστήριο 7: Ο αλγόριθμος ταξινόμησης Radix Sort Εργαστήριο 7: Ο αλγόριθμος ταξινόμησης Radix Sort Στην ενότητα αυτή θα μελετηθούν τα εξής επιμέρους θέματα: -Ο αλγόριθμος ταξινόμησης Radix Sort -Δυο εκδοχές: Most Significant Digit (MSD) και Least Significant

Διαβάστε περισσότερα