From c9122c7488a6ed608f6da1282c50b857761c9f84 Mon Sep 17 00:00:00 2001 From: ys554 <ys554@cs.drexel.edu> Date: Tue, 19 Feb 2019 21:23:56 -0500 Subject: [PATCH] lab 6 --- lab06/l6 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lab06/l6 diff --git a/lab06/l6 b/lab06/l6 new file mode 100644 index 0000000..aa6d791 --- /dev/null +++ b/lab06/l6 @@ -0,0 +1,69 @@ +Yegeon Seo +Lab 6 Data Structures and Algorithms + +Q1. + +a. List - List is a linear collection of data elements called nodes, each pointing to the next node as a pointer. The beginning of the linked list is the head value that points to the first item in the list while the last item points to null. + +b. Stack - A data structure that uses Last In First Out (LIFO) + +c. Queue - A data structure that uses First In First Out (FIFO) + +d. Dictionary - Set of two lists that where one of the values in the second list corresponds to one or several keys in the first list. + +Q2. O(log2(n)) (base 2) times + +Q3. O(n) times + +Q4. When the list is not sorted. Binary search only uses sorted lists. + +Q5. +First Pivot: +*84* 37 93 82 98 27 63 73 93 27 75 55 45 8 + +37 82 27 63 73 27 75 55 45 8 *84* 93 98 93 +*37* 82 27 63 73 27 75 55 45 8 84 *93* 98 93 +27 27 8 *37* 82 63 73 75 55 45 84 *93* 98 93 +*27* 27 8 37 *82* 63 73 75 55 45 84 93 *98* 93 +8 *27* 27 37 63 73 75 55 45 *82* 84 93 93 *98* +8 27 27 37 *63* 73 75 77 45 82 84 93 93 98 +8 27 27 37 45 *63* 73 75 77 82 84 93 93 98 +8 27 27 37 45 63 *73* 75 77 82 84 93 93 98 + +Last Pivot: +8 27 27 37 45 63 73 *75* 77 82 84 93 93 98 + +Quicksorted List: +8 27 27 37 45 63 73 75 77 82 84 93 93 98 + +Q6. +[3 -> 24 -> 06] + +Q7. +[13, [28, [24, [3, none] ] ] ] + +Q8. +Two outputs are different because s is not being pointed at the buffer, so when s is changed, the buffer is not causing the output to display two different values of the pointers. + +Q9. +3 -> [Bob,38],[Cos,86] +4 -> [Vera,99],[Nash,11],[Kate,28],[Jaga,24] +5 -> [Jesse,78] + +Q10. + +int find( char *key, int *p_ans ){ + +while (key != NULL) { + +if(*key == *p_ans){ + return 1; +} + +key = key->next; +} + +return 0; +} + + -- GitLab