Skip to content
Snippets Groups Projects
Commit c9122c74 authored by ys554's avatar ys554
Browse files

lab 6

parent 95390697
No related branches found
No related tags found
No related merge requests found
lab06/l6 0 → 100644
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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment