Domanda |
Risposta |
1. Describe a data structure. Give an example of a Data Structure. inizia ad imparare
|
|
a collection of data values, the relationships among them, and the functions or operations that can be applied to the data. eg a Stack Queue or List
|
|
|
2. Describe the four different categories of data structures. inizia ad imparare
|
|
Linear, Hierarchical, set, Graphs
|
|
|
3. Describe an Abstract Data Type (ADT). What is the function of an ADT? inizia ad imparare
|
|
An ADT is a collection of data and associated methods stored as a single module. What is the function of an ADT?
|
|
|
4. Explain what is meant by O(n). inizia ad imparare
|
|
Linear time exicution, as the number of elements (n) increases so does operational time
|
|
|
5. Explain what is meant by O(1) inizia ad imparare
|
|
Constant time exicution, the method will always execute in 1 time unit
|
|
|
6. Describe the technique of recursion. inizia ad imparare
|
|
solving a large problem by solving the same problem with a smaller scope, repeating the recursive step until the base case is reached. The case being a known answer
|
|
|
7. Explain what is meant by Tail End Recursion inizia ad imparare
|
|
there is one recursive call in an algorithm and this call is the very last thing the done.
|
|
|
8. In recursion explain what is backtracking inizia ad imparare
|
|
Backtracking is a systematic trial and error approach to finding the solution to a problem. Backtracking algorithms are useful where initially there appear to be many solutions but few survive further tests.
|
|
|
9. Describe linear search algorithm inizia ad imparare
|
|
a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
|
|
|
10. Describe binary search algorithm inizia ad imparare
|
|
finds the position of a target value within a sorted data structure.
|
|
|
inizia ad imparare
|
|
A queue is a collection of objects organised such that the object that has been stored in the queue the longest is the next one removed A queue is a linear data structure
|
|
|
inizia ad imparare
|
|
A stack is a collection of objects where only the most recently inserted object can be removed at any time. A stack is a linear data structure. Last-In First-Out structure – LIFO
|
|
|
13. Describe a Singly Linked List inizia ad imparare
|
|
Linked list is a collection of objects, called nodes Every node has two components information to be stored (the data) reference to the next node (often called a link).
|
|
|
inizia ad imparare
|
|
Extension of an ordered SLL with Additional forward links, added in a randomized way. Probabilistic data structure Based on a set of parallel linked lists
|
|
|
15. Describe the process of inserting a new node into a Singly Linked List inizia ad imparare
|
|
The list is empty. New node inserted as the only node The list is not empty. New node inserted somewhere within the list New node inserted at the front of the list. New node inserted at the end of the list.
|
|
|
16. Describe the process of inserting a new node into a SkipList inizia ad imparare
|
|
Determine level by using a probabilistic technique a random number generator to determine level of insertion. Find where to insert you will need to build an array to hold references for each level. Insert by adjusting references at each level
|
|
|
inizia ad imparare
|
|
Hashing involves using an array for the efficient storage and retrieval of information
|
|
|
18. Describe 2 method of handling collisions in a has table inizia ad imparare
|
|
Collision Resolution with Chaining a linked list at each hash site Collision Resolution with Open Addressing change the hash site for a conflict
|
|
|
19. What is the big-O time complexity of traversing a singly linked list? Explain your answer. inizia ad imparare
|
|
O(n) for unsorted data using linear search or O(log2n) for sorted data using binary search
|
|
|
20. What are the disadvantages of using a linked list inizia ad imparare
|
|
They use more memory than arrays because of the storage used by their pointers. Nodes in a linked list must be read in order from the beginning as linked lists are inherently sequential access.
|
|
|
21. Describe a Binary Tree inizia ad imparare
|
|
consists of a collection of nodes (elements) where each node has a unique predecessor and many successors. every node is of degree two or less.
|
|
|
22. Describe a Binary Search Tree inizia ad imparare
|
|
Keys in the left subtree of the root precedes the key in the root Key in the root node precedes the keys in the right subtree Left and right subtrees of the root are also BSTs
|
|
|
23. Define the height of a tree inizia ad imparare
|
|
The height of a tree is the number of edges on the longest downward path between the root and a leaf
|
|
|
24. Define the level of a node in a tree inizia ad imparare
|
|
The level of a node is defined by 1 + the number of connections between the node and the root. or level = depth + 1
|
|
|
25. Create/build a Binary Search Tree from a given set of data. inizia ad imparare
|
|
|
|
|
26. Define the Depth First Traversal of a binary tree. What data structure is used? inizia ad imparare
|
|
proceeds along a path from the root through one child to the most distant descendant of that first child before processing the second child. Implementation uses a stack
|
|
|
27. Define the Breadth First Traversal of a binary tree. What data structure is used? inizia ad imparare
|
|
proceeds horizontally from the root to all of its children then to its children’s children and so on... Implementation uses a queue.
|
|
|
28. A full binary tree consists of 2n+1 nodes. How many of these nodes will be leaf leaves? Explain why. inizia ad imparare
|
|
(n+1)/2. In the simplest case a binary tree with a root node, a left and a right has 3 nodes, two of which are leaf nodes.
|
|
|
29. What is the maximum number of nodes in a binary search tree of height h? Explain your answer. inizia ad imparare
|
|
2n-1 where n = height, Given thatThe maximum number of nodes: in a BST of height 1 = 1 , in a BST of height 2 = 3 (The tree now has 1 node on level 0 and two nodes on level 1) in a BST of height 3 = 7
|
|
|
30. A binary Search Tree is created by inserting numbers in numerical order. What do you know about the shape of this tree? Explain why. inizia ad imparare
|
|
You get a simple list as the creation of the BST sorts the data
|
|
|
31. What is postfix notation? inizia ad imparare
|
|
an alternative way that can be used to represent an expression with the opperators after the opperands There is only one way to represent an expression using Postfix notation. This notation is used in Complier design to generate our unambiguous code
|
|
|
32. What is an expression tree or parse tree? inizia ad imparare
|
|
is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar.
|
|
|