Loading…

1.
10 bits is equal to about how many decimal digits?: 3

2.
32-bits can represent about how many decimal digits?: 9

3.
64-bits can represent about how many decimal digits?: 19

4.
A long is how many bits?: 64 bits, or about 19 decimal digits.

5.
An int is how many bits?: 32

6.
Describe how log(n) grows.: Slowly. log(1000) = 10, log(1,000,000) = 20, log(1,000,000,000) = 30.

7.
Determine the Big O of the following code:

for ( i = 0; i < n; i++)

{

for (j = 0; j < n; j++)

{

sum += a[i][j];

}

}: O(n²)

for ( i = 0; i < n; i++)

{

for (j = 0; j < n; j++)

{

sum += a[i][j];

}

}: O(n²)

8.
For reference types, what do == and != test?: The equality of pointer values (i.e. do they have the exact same data address in memory?)

9.
How big is a pointer?: 64 bits on modern machines.

10.
How can you find the Big O of a loop?: The loop count times the Big O of the contents

11.
How can you find the Big O of an if statement?: The max of the Big O of the test, then statement, and else statement

12.
How does the constructing of a linked list work?: A linked list links new elements onto the front of the list.

13.
How many children can a node have?: Any number

14.
How many links does a node that isn't the root have coming into it?: Exactly one

15.
In a Cons list, first and rest have different types. What are they?: First can be any Object type, while rest is a Cons or null

16.
O(log(n)) is better than which function?: O(N). Much, much better.

17.
Since log(n) grows at the rate it does, what number can it be compared to?: 1

18.
state: a description of a state of a process, such as a board game; a set of variable values.

19.
To compare against null, what should be used?: == or !=

20.
To make an Integer out of an int, what should be used?: Integer myInteger = Integer.valueOf(myInt);

Integer myInteger = myInt; // autoboxing

Integer myInteger = myInt; // autoboxing

21.
What are base cases?: Simple inputs for which the answer is obvious and can be determined immediately.

22.
What are contents of a linked list?: Something as simple as a number, or a pointer to another linked list

23.
What are the advantages of LinkedList?: getFirst, addFirst, removeFirst, getLast, addLast, removeLast are all O(1)

24.
What are the advantages to ArrayList?: get and set are O(1), and add and remove at the end are O(1) so it makes a good stack

25.
What are the different representations of trees that we are concerned with for Novak's class?: Binary trees, First-Child/Next-sibling, Linked lists, Implicit

26.
What are the disadvantages of ArrayList?: add and remove are O(N) for random positions, contains is O(N)

27.
What are the disadvantages of LinkedList?: get, set, and remove are O(N)

28.
What are the two fields of a cons cell called?: car and cdr (original names), or first and rest.

29.
What does a recursive program do?: It calls itself as a subroutine.

30.
What does a sentinel node hold or reference?: nothing; a sentinel is an extra node, usually at the front or end, that simplifies coding.

31.
What does depth-first search do?: It searches children of a node before siblings are considered (through recursion)

32.
What does it mean for a function to be intractable?: It can only be computed when n is relatively small (for example, if the function is exponential)

33.
What does it mean for functions to share structure?: The same list structure is part of more than one list.

34.
What does it mean for something to be random access?: Access to any element has the same cost, O(1); (for example, arrays)

35.
What does it mean to divide and conquer?: To break down a large problem into two smaller problems, until the problem becomes easy

36.
What does the following linked list produce?

(cons 'a '(b c)): (a b c)

(cons 'a '(b c)): (a b c)

37.
What does the following produce?

(rest (rest '((a b) c))): null

(rest (rest '((a b) c))): null

38.
What does the function append() do to a linked list?: It concatenates two lists to form a single list.

(append '(a b c) '(d e)) = (a b c d e)

(append '(a b c) '(d e)) = (a b c d e)

39.
What does the function assoc do?: It provides a simple lookup tool to find information in a linked list. (assoc 'b '((a 1) (b 2) (c 3))) = (b 2)

40.
What does the function (cons item list) do?: It makes a new list element containing item, and adds it to the front of list

41.
What does the function Intersection do?: It returns a set of elements that are members of both sets. (intersection '(i c e) '(c r e a m)) = (e c)

42.
What does the function member do?: It tests whether a given item is an element of a list. It returns the remainder of the list beginning with the desired element

43.
What does the function merge do?: It combines two sorted lists into one sorted list. Duplicated elements are retained.

44.
What does the function nconc do?: It concatenates two lists to form a single list; it does so by modifying the end of the first list to point to the second list

45.
What does the function nreverse do?: It reverses a list in place by turning the pointers around.

46.
What does the function reverse() do to a linked list?: It makes a new linked list whose elements are in reverse order of the original list

47.
What does the function Union do?: It returns the set of elements that are members of either set (basically all elements with no duplicates).

(union '(i c e) '(c r e a m)) = (i c r e a m)

(union '(i c e) '(c r e a m)) = (i c r e a m)

48.
What is a binary tree?: A tree in which each node has at most two children

49.
What is a circularly linked list?: The last link points back to the front of the list rather than to null or nil

50.
What is a Cons?: The function that constructs a pair containing two pointers

51.
What is a constructive function?: A function that creates a new list, but does not modify the original list's arguments

52.
What is a destructive function?: A function that modifies the original list's arguments

53.
What is a doubly linked list?: It has pointers that point both forward and backward

54.
What is a fair data structure?: An entry in a queue will eventually get serviced and removed so a queue is fair

55.
What is a First-Child / Next-Sibling Tree?: Down arrows represent the first child, while side arrows represent the next sibling

56.
What is a link?: A pointer to the next element

57.
What is a link?: A directed pointer from one node to another

58.
What is a linked list?: A data structure where each element has two fields: a link and contents

59.
What is an abstract data type?: a description of operations on a data type that could have multiple possible implementations.

60.
What is an association list?: It is a list of pairs, where each pair has a key, and a value associated with the key. ((one 1) (two 2) (three 3))

61.
What is an object?: a data structure that can be identified at runtime as a member of a class

62.
What is a node with no children called?: a leaf

63.
What is a parent?: In a tree, it is a node that points to a given node

64.
What is a pointer (aka reference)?: The memory address of the beginning of a record, or block of storage

65.
What is a reference?: A pointer to data

66.
What is a root?: The uppermost tree node that has no incoming links

67.
What is a runtime stack?: a stack that keeps a fresh set of values for each variable in a stack frame

68.
What is a "thing" concerning linked lists?: A simple item such as a number or string or a balanced pair of parentheses and everything inside of them.

69.
What is a tree?: A kind of graph composed of nodes and links. It has one root node. Each node except the root has exactly one parent. All nodes are reachable from the root.

70.
What is design pattern?: a pattern that describes a set of similar programs

71.
What is garbage?: it can be data that is incorrect, meaningless, or random, or storage that is no longer pointed to

72.
What is inorder?: an order of processing a tree in which the parent node is processed in between its children

73.
What is preorder?: a way of processing a tree where the parent node is processed before the children

74.
What is random access?: describes a data structure in which all accesses have the same costs, O(1). e.g. an array.

75.
What is similar to people waiting in line?: A queue

76.
What is sometimes called a boxed integer?: Integer in Java, a record that has a class, has methods, can be pointed to and used in other structures.

77.
What is the best way to remember how to draw a FC/NS Tree?: It looks like an ordinary tree, but the right hand links all fall down and become horizontal.

78.
What is the Big O of accessing some element in the middle of a LinkedList?: O(N)

79.
What is the Big O of accessing some element in the middle of an ArrayList?: O(1)

80.
What is the Big O of a matrix multiply?: O(n³)

81.
What is the Big O of binary search?: O(log(N))

82.
What is the Big O of inserting at the front of a LinkedList?: O(1)

83.
What is the Big O of inserting at the front of an array or an ArrayList?: O(N)

84.
What is the Big O of inserting in the middle of an ArrayList?: O(N)

85.
What is the Big O of linear search of arrays, ArrayList, and LinkedList?: O(N)

86.
What is the Big O of quicksort?: O(n*log(N)), but could be O(n²) in the worst case.

87.
What is the Big O of selection sort?: O(n²)

88.
What is the goal?: The item being sought in a search

89.
What is the output:

(intersection '(a b c) '(a c e)): (c a)

(intersection '(a b c) '(a c e)): (c a)

90.
What is the output:

(member 'dick '(tom dick harry)): (dick harry)

(member 'dick '(tom dick harry)): (dick harry)

91.
What is the term for items being inserted at the end of a queue?: enqueued

92.
What is the term for items being removed from the front of a queue?: dequeued

93.
What is well-founded ordering?: ordering that can guarantee to terminate (go down to zero)

94.
What is XML?: Extensible Markup Language, it allows users to put tags around their data to describe what the pieces of data mean. <city> Austin </city>

95.
What should be used to test the equality of the contents or value of a reference type?: .equals()

96.
What will a filter function do?: Filter removes items from a Collection if they meet a certain condition

97.
When the ratio of times as the size of input is doubled is about 2, what is the Big O?: O(n)

98.
When the ratio of times as the size of input is doubled is about 4, what is the Big O?: O(n²)

99.
When the ratio of times as the size of input is doubled is about 8, what is the Big O?: O(n³)

100.
When the ratio of times as the size of input is doubled is somewhat larger than 2, what is the Big O?: O( n*log(n) )

101.
When there is a straight line on a log-log graph, what does the slope represent?: The exponent of the polynomial, e.g. slope of 2 is O(n²).

102.
Which algorithms show up as straight lines on log-log graphs?: Polynomial

103.
Which function will produce a linear plot on semi-log paper?: Exponential

104.
With respect to linked lists, what does .set(idx, element) do?: Replaces the element at the specified position in this list with the specified element.

105.
With respect to linked lists, what does the function length() produce?: The number of "things" in the linked list

## CS 314 Mid Term ReviewStudy online at quizlet.com/_6awjq |

table

glossary

Print the PDF. Fold each page down the middle along the dotted vertical line and cut the solid horizontal lines.

If your printer has a special "duplex" option, you can use it to automatically print double-sided. However for most printers, you need to:

**Print the "odd-numbered" pages first**- Feed the printed pages back into the printer
- Print the "even-numbered" pages

**If your printer prints pages face up**, you may need to tell your printer to reverse the order when printing the even-numbered pages.

Please use the "Open PDF" button to print your set.

**Why?**
In order to provide a consistent printing experience across different computers and web browsers, we've provided a standard PDF format for you to print.

Create Set
or
### Need an account?

Sign up for free