CSD

¡Supera tus tareas y exámenes ahora con Quizwiz!

Identify the data structure which allows deletions at both ends of the list but insertion at only one en

Input-restricted deque

Node p1,p2; p1 = p.next;

It deletes the node after P

Which graph representation is best?

It depends on the problem

Where does the term queue come from?

It is a British reference to waiting in line. Fist in, first out.

Which of the following statements about the shortest path finding algorithm of Dijkstra is true?

It is label-setting algorithm

Unless its a link a 2-3-4 tree node with one data item must have at least how many links?

2

What is the list after the FIRST TWO steps of insertion sort?

2, 5, 16, 11, 10, 8, 12, 3, 8 ,6

Consider the list of ten integers below: 16, 5, 2, 11, 10, 8, 12, 3, 8, 6 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest)

2, 5, 16, 11, 10, 8, 12, 3, 8, 6

A leaf node has no children but can contain up to how many data items?

3

Consider the following function: void quiz(int n) {if (n > 1) {quiz(n / 2); quiz(n / 2); } System.out.print("* "); } How many asterisks are printed by the function call quiz(5)?

3

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?

3

For the call h(3), how many calls to h will be made, including the original call?

3

How many parts are there in a declaration statement

3

Suppose the f(n) function is defined on the set of integer numbers as below

3

Suppose the f(n) function is defined on the set of integer numbers as below. What is the value of f(-5)?

3

The complexity of this algorithm is:

3

void quiz(int n) {if(n>1){quiz(n/2);

3

what is the value of f(-5)

3

Consider the list of eight integers below: 6, 4, 9, 10, 8, 3, 7, 5 What is the list after it has just been partitioned by the first step of quicksort and a pivot value is chosen as the first element of the list? (sorting from smallest to largest)

3, 4, 5, 6, 8, 10, 7, 9

Considering the list of eight integers below: 6, 4, 9, 10, 8, 3, 7, 5 What is the list after it has just been partitioned by the first step of quicksort and a pivot value is chosen as the first element of the list?

3, 4, 5, 6, 8, 10, 7, 9

what is the list after it has just been partitioned by the first step

3, 4, 5, 6, 9, 11, 7, 10

What is the breadth-first traversal of a tree below after deleting the node 15 by merging?

30 5 40 10 35 25 20

what is the breadth-first traversal of a tree below after deleting the node 15 by merging?

30,5,40,10,35,25,20

Consider the AVL tree below. What is the preorder traversal of the tree after deleting the node with value 40?

32, 22, 12, 27, 35, 45

what is the breadth first traversal of the tree after inserting a node with value 24

35,22,39,12,27,37,24,32

Given a raw message 'BBBUUUUBBBUUBBBBBUU'

3B4U3B2U5B2U

FFFOOOOFFFOOFFFFFOO

3F4O3F2O5F2O

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T?

4

What is the list after the FIRST iteration (for i=0 to n-2) in a bubble sort?

4, 6, 9, 2, 8, 1, 3, 7, 5, 10

The following is the main part of bubble sort pseudocode:

4.6.10.2.9.1.3.7.5.11

Given a weighted graph below. What is the total edge-weight of the minimum spanning tree of G?

48

Suppose the h(n) function is defined on the set of integer numbers as below. For the call h(3), how many calls to h will be made, including the original call? return(h(n-1)+h(n-2));

5

What is the breadth-first travesal of a tree below after deleting the node 2 by copying

5,1,7,4,6,8,3

what is the breadth-first traversal of a tree below after deleting the node 2 by copying?

5,1,7,4,6,8,3

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e.p.info=3): (head)7 1 6 4 3 9 8 2(tail)

7 1 6 4 3 8 2

(head) 7 10 6 4 2 13 8 3 (tail)

7 10 6 4 2 13 8 5 3

class A {int a, b; void set(int a1, int b1){a=a1; b=b1;} int foo() {return(a+b);}} public class Main {static void test(A h) {h.a = h.a + 2; System.out.print(h.foo()+ ? ?);} public static void main(String [] args){A t = new A(); t.set(3,4);

7 9 7

class A{int a,b; void set(int a1, int b1){a = a1;b = b1;}}

7 9 7

What is the output of the code snippet below?

7 9 9

7, 8, 3, 1, 2, 5, 9

7, 3, 8, 1, 5, 9, 2

what is the minimum number of node in a nearly complete binary tree with height 4?

8

What is the value of the Boundary Folding Hash Function if K = 43-65-76-7 and TSize = 100?

82

In which order does a postorder traversal visit the nodes of the above tree

9 23 14 34 47 39 30 61 79 84 72 53

Preorder: J C B A D E F I G H Inorder: A B C D E F J G I H

A B E F D C G H I J

Why do we prefer a B-tree to a general multi-way tree?

A B-tree is guaranteed to never degenerate, all of its leaves stay on the same level, every internal node has at least some minimal number of children.

Which statement concerning the switch construct is true in Java?

A character literal can be used as a value for a case label

int x; is an example of:

A loop creator.

Select a correct statement about singly linked lists.

A node with a specified value (info) can be found by traversing the list

What is a subtree?What is a subtree?

A node with two children. The children have no children.

Select the statement that is the most correct

A recursive method is a method that invokes itself directly or indirectly

What is the chain to begin with A5?

A5-B5-A9-B9

Using the Huffman code tree below. What is the result of decoding the string: 1100000001100 ?

AABBBCAB

Choose the false option from the following sentences

Accessing arrays or string elements

Which of the following is the feature of stack

All operations are at one end

Which of the following is the feature of stack?

All operations are at one end

Why do we prefer an AVL tree to a more general binary search tree?

An AVL tree is guaranteed to never degenerate.

Given a graph below (See picture). What is the output of depth-first traversal from vertex B?

B, A, E, G, C, F, D, H

Given a graph below. What is the output of depth-first traversal from vertex B? (visit nodes in ABC order if there are some nodes having the same selection ability)

B, A, E, G, C, F, D, H\

Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex B to the vertex F. What are the correct order of

B, C, D, E, F

cycle. The following is an algorithm for finding Euler cycle from the vertex X using stack:

B, D, C, B, A, B

In a graph if e=(u, v) means

B.e begins at u and ends at v C. u is processor and v is successor

Given a graph below. What is the output of breadth-first traversal from vertex C? (visit nodes in ABC order if there are some nodes having

C, B, D, A, R, G, F, H

What is valid topological sort of the graph shown below

C,A,E,B,D,F,H,G

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

DCBA

What are programmer's tools?

Data structure storage that is accessed by the program itself. Ex - stacks and queues.

Select correct statement(s) about Doubly Linked List:

Deleting a node at.. && The node which is deleted..

Which of the following operations take O( 1)time:

Deleting one node..&& Searching one node

What is the access unit of a hard disk?

Disk block

The depth of a complete binary tree is given by

Dn = log2n + 1

The depth of a complete binary tree is given by

Dn = log2n+1

How the queue looks like after processing the input

(2)

75, 12, 110, 103, 32, 132

(3)

What is the expression for generating a pseudorandom number in the range 1...N?

(int) (Math.random() * N) + 1;

Suppose temp refers to a node in a linked list (using the SLLNode class with instance variables called info and next). What boolean expression will be true when temp refers to the tail node of the list?

(temp.next == null)

what is the output when the statement fun(5); is run?

*****-***-*-That's all

To implement an AVL tree, a concept balance factor is introduced

-1

To implement an AVL tree, a concept balance factor is introduced (ball = height(right)-height(left). Suppose an AVL tree is created by inserting to the tree the following keys sequentially: 5, 2, 6, 1, 3, 4 What is the balance factor of the node 2?

-1

Consider the implementation of the Stack using a partially-filled array. What goes wrong if we try to store the top of the Stack at location [0] and the bottom of the Stack at the last used position of the array?

. Both push and pop would require linear time.

What is the correct definition of a hash table?

...used for storing items or their addresses... i = h(x) in the table.

6, 4, 7, 3, 5, 2

0

6, 4, 7, 3, 5, 2 What is the balance factor of the node 4?(please note that the tree is still AVL)

0

To implement an AVL tree, a concept balance factor is introduced (bal=height(right)-height(left). Suppose a AVL tree is created by inserting to the tree the following keys sequentially

0

to implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left))

0

void fun(int n) {if(n > 0) { n = n/5; fun(n); System.out.print(" " + n); } } What is the output when the statement fun(23); is run?

0 4

The complexity of heap sort is

0(nlog n)

Suppose the frequencies of use of characters are given by: E [40%], A [30%], M [20%], N [5%], T [5%] What is the Huffman code of M?

001

Suppose the frequencies of use of characters is given by: A [10%], B [20%], C [70%] We want to improve the average length of the codeword by applying the Huffman algorithm to pairs of letters instead of single letters. What is the Huffman code of AB?

0010

What is the color of the vertex E?

1

sum(b, n) = 1 + b*(1 + b*(1 + b*(1 + ... + b)))

1 + b * sum(b, n - 1)

See picture:

1 0 1 1

To create an object in Java you must do two things:

1. Use the keyword "new"

Select incorrect statement about restrictions need to be imposed on the prospective codes:

Each codeword may be corresponds to one or many symbols.

Specify the correct statement about open addressing method for handing collision

Each position of the table is associated with a linked list or chain of structures

Thus, mergesort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge(data,first,last) step?

Elements in each half of the array are sorted amongst themselves.

The Order followed by stack data structure is

FIFO

_______ form of access is used to add and remove nodes from a queue

FIFO , First In First Out

A balanced tree is one whose root has many more left descendents than right

False

Depth-first traversal can not be implemented if ,A recursive implementation of preorder tree trav,There are six possible ordered depth-first traversal

False

In the array implementation, dequeuing can be executed in O(n)

False

In the array list, poping is executed in O(lgn) to the worst case

False

In the doubly linked list implementation of queue, enqueuing can be executed in constant time O( n).

False

State True or False:"In a binary search tree,all the nodes that are left descendants of node A have key values greater than A;all the nodes A's right descendants

False

pointers store the next data element of a list

False

The search time is O(lgn) in the worst case , In 20-element skip lists, the node in position 3 points to the

False about skip list

(1) A drawback of a balanced tree is the search-time may be out of control

False, true, false

In the linked-list version of the Queue class, which operations require linear time for their worst-case behavior?

False=(getFront, isEmpty, insert )

In the circular array version of the Queue class, which operations require linear time for their worst-case behavior?

False=(getFront, isEmpty, insert when the capacity has not yet been reached)

In the array version of the Stack class, which operations require linear time for their worst-case behavior?

False=(is_empty,peek,pop,push when the stack is below capacity)

In the linked-list version of the Stack class, which operations require linear time for their worst-case behavior?

False=(is_empty,peek,pop,push)

what is written to the screen for the input "HowAre***You**To****Day"

HowAreYou

Consider the following pseudocode: What is written to the screen for the input "H*owAre***You**To****Day" ?

HowAreYouT

What is writen to the screen for the input"H*owAre***You**To****Day"?

HowAreYouT

what is written to the screen for the input "H*owAre***You**To****Day"?

HowAreYouT

decoding the string: 0111000000101

CAABBBAC

Specify the correct statement about bucket addressing method for handling collision (select the best answer)

Colliding elements in the same position in the hash table are placed on a bucket assosiated with that position

The space factor when determining the efficiency of algorithm is measured by

Counting the maximum memory needed by the algorithm

arr = new long [100];is an example of:

Creating an array.

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is

D

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.The popped item is.

D

Given a graph below. What is the output of depth-first traversal from vertex D? (visit nodes in ABC order if there are some nodes having the same selection ability).

D, C, B, A, E, G, F, H

Give a graph below. What is the output of breadth-first traversal from vetex D?(visit nodes in ABC order if there are some nodes having the same selection ability).

D, C, F, B, G, A, E, H

Given a graph below. What is the output of breadth-first traversal from vertex D? (visit nodes in ABC order if there are some nodes having the same selection ability).

D, C, F, B, G, A, E, H

What is the ouput od breadth-first traversal from vertex D

D,C,B,A,E,G,F,H

Selectionsort and quicksort both fall into the same category of sorting algorithms. What is this category?

Interchange sorts && Worst time is quadratic

What is the difference between internal search and external search?

Internal search utilizes and accesses memory while an external search utilizes and accesses the hard disk or other secondary storage device.

Consider the fun() method in a singly linked list below: void fun() { if(isEmpty()) return; if(head == tail) head = tail = null; else { Node p1,p; p1 = null; p = head;}}..

It remove a node at the end of the list

head = tail = null;

It removes a node at the end of the list

Specify the correct statement about the fun() method in the code above (choose the most suitable one).

It removes the first element of the list

The Worst case occur in linear search algorithm when

Item is the last element in the array or is not there at all

An advantage of a linked list is

Its size can be expanded and shrunk rapidly.

Peope = {George, Jim, Jean, Frank, Fred, John, Susan} Friendship = {(George, Jean), (Frank, Fred), (George, John), (Jim, Fred), (Jim, Frank), (Jim, Susan), (Susan, Frank)}

John and Jean

Which of the following applications may use a stack?

Keeping track & A parentheses & Syntax analyzer for a compiler.

Which of the following applications may use a queue?

Keeping track of local variables at run time

The memory address of fifth element of an array can be calculated by the formula

LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array

Which of the following expressions evaluates to true with approximate probability equal to P? (P is double and 0 <= P <= 1).

Math.random() < P

Whatever you can do to manipulate the data storage structure becomes our:

Methods.

The complexity of the average case of an algorithm is

Much more complicated to analyze than that of worst case

Suppose we are considering a singly linked list which has at least 2 nodes. Select the most correct java code snippet that deletes the last node.

Node f = head; while(f.next!=tail) f = f.next; f.next=null;

Suppose we are considering a doubly linked list which has at least 2 nodes. Select the most correct java code snippet that inserts new node with value x before the last node (prev is a link to predecessor node).

Node f = tail.prev; Node q = new Node(x); q.prev = f;q.next=q;tail.prve=q

Suppose we are considering a singly linked list which is not empty. Select the most correct java code snippet that inseart new mode with value x at the head of the list (the new node will be the first node in the list).

Node q = new Node(x); q.next = head; head = q;

In the array version of the Queue, which operations require O(n) time for their worst-case behavior?

None of the others

The complexity of merge sort algorithm is

O(n log n)

The complexity of merge sort algorithm is a

O(n log n)

The complexity of merge sort algorithm is a.

O(n log n)

Basically the complexity of inserting a node after a given node in a singly linked list is

O(n)

Basically, the complexity of counting the number of items in a doubly-linked list is

O(n)

the complexity of inserting new element before a given node in the middle of singly linked lists is

O(n^2)

What is the worst-case time for heapsort to sort an array of n elements?

O(nlgn)

What is the worst-case time for mergesort to sort an array of n elements?

O(nlgn)

The complexity of heap sort is

O(nlog n)

the complexity of heap sort is

O(nlog n)

The complexity of merge sort is

O(nlog2n)

To evaluate an expression without any embedded function calls:

One stack is enough.

What is the "push"?

Placing a data item on top of the stack.

In the linked-list version of the Stack class, which operation requires linear time for the worst case? Assume that addtoTail, deletefromTail are used.

Pop

Which of the following statements about the Stack are true

Popping operation in the linked .. && Popping operation in the array

What are the two types of data in java?

Primitive types (int, char, boolean,long, double etc) and objects.

What are the pros and cons of using a priority queue implemented by a simple array?

Pro: Simple and appropriate when the # of items isn't high or insertion speed isn't critical.

When converting a method from a recursive version into an iterative version,

Program clarity ..&& The brevity..java

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

Scalars, atoms, elementary items

Which of the following applications may use a stack?

Store a waiting list of printing jobs

Which of the following applications may use a stack?

Store a waiting list of printing jobs.

B, A, D, B, C, B

TRUE

Select the statement that is most correct Tail recursion is a special case of recursion in which the first operation of the function is a recursive call.

Tail recursion is a special case of recursion in which last operation of the function, the tail call, is a recursive call.

What does the [] operator tell the compiler?

That we are naming an array object.

Select incorrect statements about Object ∑Oriented Programming

The combination of data...&& Static methods and variables

Which of the following statements about graph coloring is true

The complexity of sequential Coloring algorithm is O(|V|2) ,Sequential Coloring algorithm establishes the sequence of

Specify the correct statement about hashing algorithm (Select the best answer)

The expected complexity of ...

A field in the list itself contains a reference to:

The first link.

Consider the implementation of the Queue using a circular array. What goes wrong if we try to keep all the items at the front of a partially-filled array (so that data[0] is always the front).

The getFront method would require linear time.

Consider the binary tree below. Which statement is correct?

The tree is full but not complete.

Two main measures for the efficiency of an algorithm are

Time and space

Arrays are dense lists and static data structure

True

Polish notation eliminates all parentheses from formu, Using Polish notation, all expressions have to be brok,Expression trees do not use

True

Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system.

True

Tail recursion is a special case of recursion in which the last operation of the function

True

With respect to prefix codes in an optimal system, the length of each codeword should be minimum.

True

data elements in linked list need not be stored in adjecent space in memory

True

linked lists are collection of the nodes that contain information part and next pointer

True

What is the best definition of a collision situation in a hash table?

Two entries with different keys have the same exact hash value.

Which of the following applications may use a stack?

Undo sequence in a text editor

Select the statement that is most correct Which of the following applications may use a stack?

Undo sequence in a text editor.

In a Heap tree

Values in a node is greater than every value in children of it

Select true statement(s) about Java

Variable names are..&& Characters are 16..&& For a postfix operator..

In run-length encoding algorithm, a run is defined as ∑

a sequence of identical characters

Using LZW with the table initialized with the letters a, b, c. Decode the string coded as: 2 2 3 2 4 8 4 3

aabacaccb

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

all of above

In a graph if e=[u, v], Then u and v are called

all of above

Which of the following problems may use stacks implicitly or explicitly?

all of the other

The DSW algorithm uses

all of the others

The problem of printing a string in reverse order can be implemented using

all of the others.

47 3 21 32 56 92

all of them

A linked list index is ____ that represents the position of a node in a linked list

an Integer

A linked list index is ____ that represents the position of a node in a linked list.

an Integer

New nodes are added to the _____ of the queue

back

New nodes are added to the _____ of the queue.

back

The memory address of the first element of an array is called

base address

Fill in blank to form a correct statement: "A recursive method is a method that invokes itself directly. For a recursive method

base cases

What is written to the screen for the input "Good**Mor*ni***ng"?

dorino

A _____ node contains some data and one link to its successor and one link to its predecessor in the list.

doubly linked list

The operation for adding an entry to a a queue is traditionally called:

enqueue

Let? look at the recursive algorithm that generates Fibonacci numbers. This algorithm belongs to type recursive algorithm ∑

excessive

A balanced tree is one whose root has many more left descendants, or vice versa

false

An activation record contains code of method owning it

false

An activation record still exists after a method owning it ends

false

If every proper subtree of a binary tree is full, then the tree itself must also be full.

false

In Insertion Sort, the number of movements and comparisons for a randomly ordered array is closer to the best case

false

In all cases, nonrecursive implementation is faster recursive implementation

false

Only insertion sort is apllied in all h-sorts of shell sort.

false

Shell sort divides the original array into physical subarrays, sorting them separately, then merging and dividing them again to sort the new subarrays until the whole array is sorted.

false

State True or False:"In a binary search tree, all the nodes that are left descendants of node A have key values greater than A; all the nodes that are A's right descendants have key values less than (or equal to) A."

false

The best case of quick sort happens when bound is the largest (the smallest) element of the array.

false

The number of 0 entries in an adjacency matrix is twice the number of edges.

false

The postorder traversal always visits the right-most node first.

false

The worst case is when the bound divides an array into subarrays of approximately length `n/2`

false

in a singly-linked list , there is no efficient way to insert a node before a given node in the middle or the end of the list..

false

Arrays are best data structures

for relatively permanent <benvung> collections of data

Arrays are the best data structures

for relatively permanent collection of data

Array are the best data structures

for relatively permanent collections of data

Arrays are the best data structures

for relatively permanent collections of data

Linked lists are best suited

for relatively permanent collections of data

I have implemented the queue with a linked list, keeping track of a front node and a rear node with two reference variables. Which of these reference variables will change during an insertion into an EMPTY queue?

front changes., rear changes.

void fun(int n)

fun(-1023)

which call will result in the most recursive calls?

fun(-1023)

which call will result in the most recursive calls ?

fun(-1025)

What is written to the screen for the input"Good**Morn**in***g"?

gMoG

The _______ function retrieves the value of the size member of the LinkedList class

getSize()

what is written to the screen for the input "Good**Morn**i***ng"

gnoM

Which of the following is two way list?

grounded header list;circular header list;linked list..nodes=False

what is the correct definition of a hash table?

hash table T is used with a hash function h(x), which transforms a particular key x, into an index i = h(x) in the table

Specify the correct implementation of pop() method of

if is empty return null return integer pool.removelast

select the most correct statement:

in a linked list, the tail node is introduced for performance purpose only

Specify the most correct statement about chaining method for handling collision

in this method...

Select the statement that is most correct

in which the last operation of the function, the tail call, is a recursive call

A recursive implementation of preorder tree traversal uses stack explicitly

incorrect

Give a weighted graph below and you are using the Dijkstra algorithm to find the sortest path from the vetex H to the vertex T. What is the label of the vertex D when the shortest path from H to T is determined?

infinity

In a singly linked list, we can use the tail reference to ∑

insert or delete a node at the end of list easily.

Node q = new Node(x); q.next = head; head = q;

inserts new node with value x at the head of the list

specify the correct inplementation of pop() method of a stack of integers

integer pop() { if(isEmpty()) return(null); return(integer) poll.removeLast()}

specify the correct implementation of pop() method of a stack of integers. this stack uses java.util.arraylist for storing data and the end of the list is treated as the top of the stack

integer pop() {if (isEmpty()) return(null); return((integer) pool.remove(pool.size()-1))}

What is written to the screen for the input "FileComp****ress*ion**" ?

iserCeliF

Suppose we are considering a singly linked list and p is some node in the list with has successor node. What does the java code snippet below do? Node q = p.next; p.next = q.next;

it delete the node after p

Suppose we are considering a doubly linked list which has at least 2 nodes. What does the java code snippet below do? Node f = tail.rev; f.next = null; tail = f;

it deletes the last node

Node p1, p2; p1=p.next; p2=p1.next; p.next=p2; if(p2!=null) p2.prev=p;

it deletes the node after p

Suppose we are considering a doubly linked list and p is some node in the list which has successor node. What does the java code snippet below do? if(p2!=null) p2.prev=p;

it deletes the node after p.

Suppose we are considering a doubly linked list and p is some in the list which has both predecessor and successor nodes. What does the java code snippet below do? Node p1, p2; p1 = p.prev; p2=p.next; p2.prev=p1; p1.next=p2;

it deletes the node p

suppose we are considering a singly linked list and p is some node in the list which has both predecessor and successor nodes. what dose the java code snippet below do?

it deletes the node p

while(f.next!= p) f = f.next

it deletes the node p

Node f = head; while(f.next !=p) f = f.next; f.next = p.next;

it deletes the node p.

Suppose we are considering a doubly linked list and p is some node in the list which has successor node. What does the java code snippet below do? Node p1, p2; p1 = new Node(x); p2 = p.next; p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1;

it inserts new node with value x after the node p

Suppose we are considering a doubly linked list and p is some node in the list which has successor node. What does the java code snippet below do? Node p1, p2; p1 = new Node(x); p2 = p.next; p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1;

it inserts new node with value x after the node p.

Node q = new Node(x); q.prev=null; q.next = head; head.prev = q; head = q;

it inserts new node with value x at the head of the list.

Node p1 p; p1=null;p=head; while(p!=tail){p1=p;p=p.next;} p1.next=null; tail=p1;

it removes a node at the end of the list

There are two aproaches to writing repetitive algorithms:

iteration and recursion

In which order does an postorder traversal visit the nodes of the above tree:

j k e f l m g b c n h q r s o p i d a

select the statement that is most correct

keeping track of previous choices (as in backtracking)

which of the following applications mau use a stack?

keeping track of previous choices (as in backtracking)

Imagine we have the singly linked list, the head reference allows to manage this list.Show what would happen if we applied the following statements to this list?

list2 is concatenated after list1, forming an unique singly linked list

Height of a binary heap with N keys.

log N

Given the disk block size, the record size, and the pointer size, calculate the value of m.

m = lower_bound(s + r / p + r)

Suppose that you place m items in a hash table with an array size of s. What is the correct formula for the load factor?

m/s

Execution of the program starts where?

main()

Multi-programming.

may use a queue

Store a waiting list of printing jobs.

may use a queue

which of the following application may use a queue?

multi-programming

Select the statement that is most correct. Which of the following applications may use a queue?

multi-programming.

Consider the following function: int fun(int n){if(n<0)return(fun(-v));else if(n<5) return (2); else return(n*fun(n/2));} What values of n are directly handled by the stopping()base case?

n >= 0 && n <5

Consider the following function: void fun(int n) System.out.println(n%15);

n >= 0 && n<15

else if(n<35)

n >= 0 && n<35

system.out.println("n = " + n)

n >= 0 && n<35

return(n*fun(n/2)); What values of n are directly handled by the stopping (base) case?

n >= 0 && n<5

What values of n are directly handled by the stopping (base) case?

n==0&& n<35

void fun(int n){if(n < 0) {System.out.println("-"); fun(-n);} else if(n<15) System.out.println(n); else {fun(n/15); System.out.println(n%15); } }

n>=0 && n<15

what values of n are directly handled by the stopping (base) case?

n>=0 && n<15

int fun(int n) {if(n<0) return(fun(-n); else if(n<5) return(2); else return(n*fun(n/2));} What values of n are directly handled by the stopping (base) case

n>=0 && n<5

what values of n are directly handled by the stopping (base) case

n>=0 && n<5

(1) Recursive version executes slower than iterative version.

none of the other

With respect to the execution of recursive function (method), .......

none of the other

specify the correct implementation of dequeue() method of a queue. this queue uses java.util.arraylist for storing data and the head of the list is treated as the head of the queue

object dequeue() {if(isEmpty()) return(null); return(pool.remove(0));}

Specify the correct implementation of dequeue() method of a queue. This queue uses java.util.ArrayList for storing data and the head of the list is treated as the head of the queue.

object dequeue() {if(isEmpty()) return; return(pool.remove(pool.size()-1));}

Specify the correct implementation of pop() method of a stack. This stack uses java.util.ArrayList for storing data and the end of the list is treated as the top of the stack

object pop() if(isEmpty()) return(null); return(pool.remove(pool.size()-1));

specify the correct implementation of pop() method of a stack

object pop() { if(isEmpty()) return(null); reutrn(pool.remove(pool.size()-1))}

Consider the follwing pseudocode: declare a stack of characters while(there are more characters in the word to read)

odMg

declare a stack of characters while(there are more characters in the word to read) {read a character if a character is ?*? then pop the stack else push the character into the stack} while(the stack is not empty) pop and write the poped character to the screen What is written to screen for the input ?Go**odMorn**in***g??

odMg

pop the stack else push the character into the stack. What is written to the screen for the inpit "Go**odMorn**in***g"?

odMg

what is written to the screen

odMg

declare a queue of characters, which is implemented by circular array of size 6 while(there are more characters in the word to read) {read a character if a character is ?*? then dequeue the queue else enqueue the character into the queue} How the queue looks like after processing the input ?Hello***Wor**Id*??

orld

When new data are to be inserted into a data structure, but there is no available space; this situation is usually called

overflow

select the most correct java code snippet that deletes the successor node of p

p = p.next; p.next = null;

Which boolean expression indicates whether the data in two nodes (p and q) are the same. Assume that neither p nor q is null.

p.info == q.info or p.info.equals(q.info)

The operation for removing and returning the end element of the queue

peek

To create a linked list, we can allocate space and make something point to it, by writing:

pointer-variable = malloc(sizeof(struct struct-name))

that inserts new node with value x before the last node

q.prev = f;q.next = tail;f.next = q;tail.prev = q;

A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out

queue linked list

A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

queue linked list

an algorithm that calls itself directly or indirectly is known as

recursion

what is written to the screen fot the input "Go**odMorn**in***gSir"?

riSGMdo

Consider the following pseudocode: declare a stack of characters while(there are more characters in the world to read)

riSgMdo

What is written to the screen for the input "Go**odMorn**in***gSir"?

riSgMdo

What is written to the screen for the input "Good**Mor*ni***ngSir" ?

risgnMog

What is written to the screen for the input "Good**Mor*ni***ngSir"?

risgnMog

A Linked list can grow and shrink in size dynamically at

run time

A Linked list can grow and shrink in size dynamically at _______

run time

specify the reason for data compression

saving data storage

The indirect change of the values of a variable in one module by another module is called

side effect

a graph that has neither self-loop nor parallel edges are called___

simple graph

Fill in the blank of the statement to form the most correct one: In a ____ every element contains some data and a link to the next element, which allows to keep the structure.

singly linked list

Fill in the blank of the statement to form the most correct one: In a every element contains some data and a link to the next element which allows to keep the structure.

singly linked list

Fill in the blank of the statement to form the most correct one

singly lisked list

select the most correct statement

sort is 0(n^2), best case it is O(n)

Binary search algorithm cannot be applied to

sorted linear array

binary search algorithm cannot be applied to

sorted linear array

Binary search algorithm can not be applied to

sorted singly linked list

The term "push" and "pop" is related to the

stacks

If every node u in G is adjacent to every other node v in G, a graph is said to be

strongly connected

if every node u in G is adjacent to every other node v in G, a graph is said to be

strongly connected

Two dimensional arrays are also called

tables arrays && matrix arrays

Suppose that the variable temp refers to a node in a linked list (using the SLLNode class with instance variables called info and next). What statement changes temp so that it refers to the next node?

temp = temp . next ;

Suppose temp refers to the third node in the doubly linked list that has more than 5 nodes .What statement changes temp so that it refers to the first node?

temp = temp.previous.previous.next.previuos

what is written to the screen for the input "Goo***dAft**erno**on"

ternoo

What happens when you push a new node onto a stack?

the new node is placed at the front of the linked list.

in a real computer, what will happen if you make a recursive.....:

the run-time stack overflows,halting the program

in a real computer, what will happen if you make a recursive call without making the problem smaller?

the runtime stack overflows, halting the program

When representing any algebraic expression E which uses only binary operations in a 2-tree

the variable in E will appear as external nodes and operations in internal nodes

12, 13, 14, 15, 17, 19, 16, 18

true

15 65 65

true

15, 5, 25, 10, 20, 40, 35

true

2, 3, 11, 12, 5, 10, 7, 4, 8, 6

true

2, 3, 5, 6, 7, 8, 10, 9

true

2, 4, 11, 12, 5, 10, 8, 5, 9, 6

true

2, 4, 16, 11, 10, 8, 12, 3, 8, 5

true

25, 15, 40, 5, 20, 35, 10

true

3, 4, 16, 11, 10, 8, 12, 5, 8, 6

true

3, 6, 9, 1, 8, 0, 2, 7, 5, 10

true

30, 5, 40, 10, 35, 25, 20

true

35, 20, 45, 10, 25, 40, 22, 30

true

35, 20, 45, 10, 30, 40, 25, 28

true

4, 2, 7, 1, 3, 6, 8

true

4b4q3b2q5b2q

true

5, 1, 7, 4, 6, 8, 3

true

65 55 65

true

7 11 6 4 3 12 8 5 2

true

7 7 9

true

A recursive method is a method that invokes itsels directly or indirectly.For a recursive method to terminate there must be one or more base cases

true

A, B, C, D, E, C, A

true

A, B, C, E, F

true

A, B, D, E, C, A

true

Bucket is a linked list which

true

Coalesced hashing combines linear probing with chaning.

true

D, B, A, E, G, F, C, H

true

Depth-first traversal can not be implemented if ,A recursive implementation of preorder tree trav,There are six possible ordered depth-first trave

true

Linked list can be used in Bucket Addressing.

true

Linked lists allow easy insertion and deletion of information because such operations have a local impact on the list.

true

Most of the label-setting and label-correcting methods are used to find from one vertex to all other vertices.

true

Polish notation eliminates all parentheses from formu, Using Polish notation, all expressions have to be brok,Expression trees do not use

true

Polish notation eliminates all parentheses from formulas

true

Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system

true

You cannot declare integer i inside the for-lopp declaration

true

a, b, c, e, d, a

true

The situation when in a linked list START=NULL is

underflow

which of the following applications may use a stack

undo sequence in a text editor

specify the correct implementation of in-order traverse algorithm for binary trees

void inOrder(Node p) { if(p != null) { inOrder(p.left); visit(p); inOrder(p.right);}}

Which is an invalid identifier in Java?

zer@

A binary tree can easily be converted into q 2-tree

by replacing each ... new external node

A B C G E D F H

chon

ABCDEBFCADFEA

chon

All the sorting methods implemented in java is applied to any basic data type.

chon dap an none of other

A queue is implemented using a doubly linked list, which of the following operations require O( n) time?

clear (remove all elements from the queue)

I have implemented the queue with a circular array, keeping track of front, rear, and manyItems (the number of items in the array). Suppose front is zero, and rear is one less than the current capacity. What can you tell me about manyItems?

count could be zero or the capacity, but no other values could occur.

Suppose cursor refers to a node in a linked list (using the IntNode class with instance variables called data and link). What statement changes cursor so that it refers to the next node?

cursor = cursor.link;

Suppose the f(n) function is defined on the set of integer numbers as below. What is the value of f(6)

18

The operation for removing and returnning the end element of the queue is traditionally called:

dequeue

which of the following queue operations could result in queue underflow (become empty)?

dequeue

A record form a hierarchical structure but a lienear array does not

difference bw linear and record

An array is suitable for homogeneous data but hte data items in a record may have different data type

difference bw linear and record

In a record, there may not be a natural ordering in opposed to linear array.

difference bw linear and record

What are the three steps to delete an item in an array?

1.Search for the item

See picture:

10

What is output when calling TriangularNumber(4)

10

The size of a structure can be determined by

Both a and b

The size of a structure can be determined by a. size of variable name b. size of (struct tag)

Both a and b (only a va only b)

Which of the following keywords are access modifier:

Protected, Private

Finding the location of the element with a given value is

Search

Finding the location of the element with a given value is:

Search

Consider algorithm of the 8-queen problem:

The algorithm finds all solutions.

When is insertionsort a good choice for sorting an array?

The array is nearly sorted

Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through data[9]. The CAPACITY is 42. Where does the push method place the new entry in the array?

data[10]

How is a priority queue different than a queue?

A priority queue items are ordered by key value so that the item with the lowest key ( or in some implementations the highest key) is always at the front. Items are inserted in the proper position to maintain the order.

A connected graph T without any cycles is called

All of above

The difference between linear array and a record is

All of above

Which of the following data structure is linear type?

All of above

ushdown list means:

All of the above

Select correct statements:

An abstract data type can ... && Subclasses or derived classes inherit...

The in order traversal of tree will yield a sorted listing of elements of tree in

Binary search trees

How can you fix a broken sequence? What is created?

Delete enough items so that the Fron arrow wraps around. This creates a single contiguous sequence.

A data structure where elements can be added or removed at either end but not in the middle

Deque

A binary tree whose every node has either zero or two children is called

Extended binary tree

When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return

FAEKCDHGB

form of access is used to add and remove nodes from a queue

FIFO , First In First Out

A variable P is called pointer if

P contains the address of an element in DATA

An algorithm that calls itself directly or indirectly is known as

Recursion

What is "popping"?

Removing a data item from the top of the stack.

is the way you groups things together by placing one thing on top of another and then removing things one at a time from the top

Stack

which of the following applications may use a queue

Store a waiting list of printing

In a singly-linked list, these is no efficient way to insert node before a given node in the middle or at the end of the list

T

Value of the first linked list index is

Zero

Which of the following is not a limitation of binary search algorithm?

binary search algorithm is not efficient when the data elements are more than 1000.

A binary tree can easily be converted into q 2-tree

by replacing each empty sub tree by a new external node

The elements of an array are stored successively in memory cells because

by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated

If every node u in G is adjacent to every other node v in G, A graph is said to be

complete

To create a linked list, we can allocate space and make something point to it, by writing: struct-name *pointer-variable; Which of the following statement will correctly allocate the space

pointer-variable = malloc(sizeof(struct struct-name));

Which of the following statement is false?

pointers store the next data element of a list

Each array declaration need not give, implicitly or explicitly, the information about

the first data from the set to be stored

When representing any algebraic expression E which uses only binary operations in a 2-tree,

the variable in E will appear as external nodes and operations in internal nodes

Arrays are best data structures

for relatively permanent collections of data

Suppose that the Bag is implemented with a linked list. Which of these operations are likely to have a constant worst-case time?

add

In Quicksort, the bound value (pivot) may be selected as

all

Select correct statement about Ziv-Lempel Code.

all

Which of the following data structure can be implemented using Huffman Coding?

all

Which of the following definitions about a collision in a hash table are incorrect?

all

Which of the following hashing methods can cause collisions?

all

Which of the following statement about the Recursion is true

all

A linked list index is ____ that represents the position of a node in a linked list.

an integer

What member function places a new node at the end of the linked list

appendNode()

Integer pop() { if(isEmpty()) return (null); return((Integer)pool.removeLast()); }

pop() method of a stack of Integers.

A graph that has neither self-loops nor parallel edges are called____

simple graph

Every perfect balanced binary tree is also a balanced binary tree

true

a, c,d,f

true

n >= 0 && n<35

true

enque the character into the queue

uToDay

specify the corect implementation of pre-order traverse algorithm for binary tree

void preOrder(Node p) {if (p = null) {visit(p); preOrder(p.left); preOrder(p.right);}}

Which of the following can be executed in constant time O ( n )

when deleting..worst case&&when deleting..average case

The breadth-first search can be used to find the shortest path from a source vertex to the destination vertex in unweighted graph.

correct (chon all)

what is the output when the statement fun(3); is run?

$$$$$-$$$-$-hello

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is quadratic probing, i.e. when inserting a key x, the collision is resolved by finding an available position at (h(x) + i^2)%M), i=1, 2, ... How the hash table looks like after inserting the following keys sequentially?

(3)

How the queue looks like after processing the input "Hello****Worl**d*"?

(3)

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is linear probing. How the hash table looks like after looks like after inserting the following keys sequentially?

(4)

x%M, where M = 10 and collision resolution is linear

(4)

while{read a character if a character is '*' then dequeue the queue}. How the queue looks like after processing the input "Hello***Wor**ld*"

(4) 1-o 2-r 3-l 4-d

Which of the following data structure is non-linear type?

(Strings, Lists, Stacks)= False.

Which of the following data structure is linear type?

(Strings, Lists, Stacks)= True.

If data is a circular array of CAPACITY elements, and rear is an index into that array, what is the formula for the index after rear?

(rear + 1) % CAPACITY

Consider the following function: void fun(int n){if(n<=0)System.out.println("That's all!");

* *** ***** That's all!

void fun(int n) {if(n<=0) System.out.println(?That?s all!?); else {for(int i=1; i<=n; i++) System.out.print(?*?); System.out.println(); fun(n-2);}} What is the output when the statement fun(5); is run?

* *** ***** That?s all!

void fun(int n) {if (n <=0) System.out.println("That's all!"); else {for(int i = 1; i <= n; i++) System.out.print("*"); System.out.println(); fun(n - 2); } } What is the output when the statement fun(5); is run?

*(/n)***(/n)*****(/n)That's all!

The complexity of DFS is O(|V

+ |E|), where |V| is number of ve, To prevent loop from happen in an algorithm for traversing a gra | true

The complexity of DFS is O(|V

+ |E|), where |V| is number of ve, To prevent loop from happen in an algorithm for traversing a grahp | True

The complexity of Breadth First Search algorithm is O(|V

+ |E|). | true (neu co all chon all)

The complexity of DFS is `O(|V

+ |E|)` , where `|V|` is number of vertices and `|E|` is number of edges | true

How many stack will be needed for the evaluation of a prefix expression

0

To implement an AVL tree, a concept balance factor is introduced (bal=height(right)-height(left). Suppose an AVL tree is created by inserting to the tree the following keys sequentially: 6, 4, 7, 3, 5, 2 What is the balance factor of the node 4?

0

Using the shift folding method and folding two digits at a time and then modulo division of the folded sum, store the keys shown below in an array with 19 elements. How many collisions occurred?

0

else System.out.println(?StdOut: Line? + count + ?\n?); if(count == 0) return; else printOut(count-1);} What value for X the statement printOut(X); will print exactly 5 lines to standard output (Lines start with ?StdOut:?), in the fewest number of recursive calls?

10

int fun(int n) {if(n < 0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n/2)); } What is the value of fun(5) ?

10

Given the character frequencies Using Huffman encoding, what is the code for character D? (Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

100

Using Huffman encoding, what is the code for character D?(Suppose that when constructing a sub tree from 2 nodes we always place node with

100

B: 32%, C:28%, D:16%,E:6%,F:18%.Using Huffman encoding,what is the code for character E

101

int fun(int n) {if(n<0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n-2)); } What is the value of fun(6)?

12

return(n*fun(n-2)); What is the value of fun(6)?

12

what is the value of fun(6)?

12

Consider the list of eight integers (n-8) below: 15, 13, 18, 19, 17, 12, 16, 14 What is the list after it is partitioned with low = 0 and up = n-1?

12, 13, 14, 15, 17, 19, 16, 18

Partitioning is a technique used in quicksort. The following is a partition pseudocode for sorting from smallest to largest: partition the array a from index low to index up 15, 13, 18, 19, 17, 12, 16, 14 What is the list after it is partitioned with low = 0 and up = n-1?

12, 13, 14, 15, 17, 19, 16, 18

23 3 7 13 89 7 66 2 6 44 18 90 98 57

13 2 6 23 3 7 44 18 7 66 57 90 98 89

How many recursive calls to calculate the 5th Fibonacci number?

15

3 9 7 2 11 16 4 13 12

16 13 7 12 11 3 4 2 9

4 10 8 3 12 17 5 14 13

17 14 12 13 4 8 5 3 10

To implement an AVL, a concept balance factor is introduced (bal = height(right)-height(left)). Suppose an AVL tree is created by inserting to the tree the following keys sequentially: 5,2,6,1,3,4 What is the balance factor of the node 2? (please note that the tree is still AVL)

2

Consider the list of ten integers below: 8, 5, 11, 12, 3, 10, 2, 4, 9, 6 What is the list after the FIRST TWO iterations of the large loop in a selection sort?

2, 3, 11, 12, 5, 10, 8, 4, 9, 6

Suppose the frequencies of use of characters are given by: E [40%], A [30%], M [20%], N [5%], T [5%] Find the average word length using the Huffman code?

2.0

What is the breadth-first traversal of a tree below after deleting the node 5 by merging?

2.1.4. 3. 7. 6. 8

A balanced binary search tree containing one million nodes. What is the maximum number of comparisons needed to find a key in the tree?

20

What is the output of the code snippet below?

20

for(i=0;i<a.length;i++) for(j=0;j<i;j++) sum += a[j]; System.out.println(sum);

20

public class Main {public static void main(String [] args) {int [] a = {1, 2, 3, 4}; int i, j, sum; sum = 0; for(j=0;j<i;j++) sum += a[j]; System.out.println(sum);}}

20

Given a weighted graph below. What is the total edge-weight of the minimum spanning tree of G?

27

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 10 in the list(i.e. p.info=10): (head) 27 11 6 4 3 10 8 2 (tail) What does the list look like after the following java code snippet is run? int x = 19; Node p1, p2; p1 = new Node(x); p2 = p.next; p.next=p1; p1.prev=p; p1.next=p2; p2.prev=p1;

27 11 6 4 3 10 19 8 2

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 10 in the list(i.e. p.info=10): (head) 27 11 6 4 3 10 8 2(tail) What does the list look like after the following java code sippet is run?

27 11 6 4 3 10 19 8 2

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 10 in the list(i.e.p.info=10): (head)27 11 6 4 3 10 8 2(tail) What does the list look like after the following java code snippet is run?

27 11 6 4 3 10 19 8 2

What is the list after it has just been partitioned by the first step of quicsort and a pivot value

3, 4, 5, 6, 8, 10, 7, 9

16, 5, 3, 11, 10, 8, 12, 4, 8, 6 What is the list after the first two steps of insertion sort?

3, 5, 16, 11, 10, 8, 12, 4, 8, 6

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is linear probing. How the hash table looks like after inserting the following keys sequentially? 95,33,221,204,53,243

4

Select the correct statement. Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T?

4

Select the correct statement. Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T? (note: in a tree the height of root is 1)

4

Support T is a binary tree with 14 nodes. What is the minimum possible height of T?

4

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T (Note: in a tree the height of root is 1):

4

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T? (Note: In a tree the height of root is 1)

4

suppose T is a binary tree with 14 nodes. what is the minimum possible height of T?

4

What is the breadth-first traversal of a tree below after deleting the node 5 by copying?

4 2 7 1 3 6 8

What is the breadth-first traversal of a tree below after deleting the node 5 by copying?

4, 2, 7, 1, 3, 6, 8

6, 4, 10, 11, 2, 9, 1, 3, 7, 5 What is the list after the first iteration (for i = 0 to n-2) in a bubble sort?

4, 6, 10, 2, 9, 1, 3, 7, 5, 11

Consider the list of ten integers below: 6, 4, 9, 10, 2, 8, 1, 3, 7, 5 What is the list after the FIRST iteration (for i=0 to n-2) in a bubble sort?

4, 6, 9, 2, 8, 1, 3, 7, 5, 10

Considering the list of ten integers below: 6, 4, 9, 10, 2, 8, 1, 3, 7, 5 What is the list after the first iteration (for i = 0 to n-2) in a bubble sort?

4, 6, 9, 2, 8, 1, 3, 7, 5, 10

What is the breadth-first traversal of a tree below after deleting the node 5 copying?

4,3,7,1,3,6,8

What is the label of the vertex D when the shortest path from B to F is determined

7

What is the minimum number of nodes in a full binary tree with height 3? (in a tree the height of root is 1. and in a full binary tree every node other than the leaves has two children).

7

What is the minimum number of nodes in a full binary tree with height 3? find a tree the height of root is 1. and in a full binary tree every node other than tle leaves has two children).

7

What is the minimum number of nodes in a nearly complete binary tree with heigh 4?

7

void quiz(int n) {if(n>1){quiz(n/2); quiz(n/2);} system.out.print(?* ?);} How many asterisks are printed by function call quiz(5)?

7

what is the minimum number of node in a full binary tree with height 3?

7

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head) 7 1 6 4 3 9 8 2 (tail) What does the list look like after the following java code snippet is run? Node p1, p2; p1 = p.next; p2 = p1.next; p.next=p2; if(p2!=null) p2.prev=p;

7 1 6 4 3 8 2

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head)7 1 6 4 3 9 8 2(tail) What does the list look like after the following java code sippet is run?

7 1 6 4 3 8 2

Suppose a singly linked list of integers is given below: (head) 7 10 6 4 2 13 8 3 (tail) What does the list look like after the following java code snippet is run? int x = 5; Node f=head; while(f.next!=tail) f=f.next; Node q = new Node(x); q.next=tail; f.next=q;

7 10 6 4 2 13 8 5 3

Suppose a singly linked list of integers is given below: (head)7 10 6 4 2 13 8 3(tail)

7 10 6 4 2 13 8 5 3

Suppose a singly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head) 7 11 6 14 3 9 8 12 (tail) What does the list look like after the following java code snippet is run? int x = 5; Node f=head; while(f.next!=p) f=f.next; Node q = new Node(x); q.next=p; f.next=q;

7 11 6 14 5 3 9 8 12

Suppose a singly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head)7 11 6 14 3 9 8 12(tail) What does the list look like after the following java code snippet is run?

7 11 6 14 5 3 9 8 12

Suppose a singly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e.p.info=3): (head)7 11 6 14 3 9 8 12(tail)

7 11 6 14 5 3 9 8 12

Suppose a singly linked list of integers is given below. (head) 7 11 6 4 3 12 8 2 (tail) What does the list look like after the following java code snippet is run?

7 11 6 4 3 12 8 5 2

Suppose a singly linked list of integers is given below: (head) 7 11 6 4 3 12 8 2 (tail)

7 11 6 4 3 12 8 5 2

Suppose a singly linked list of integers is given below: (head)7 11 6 4 3 12 8 2(tail) What does the list look like after the following java code snippet is run?

7 11 6 4 3 12 8 5 2

Suppose a singly linked list of integers is given below and p is a reference to the node with value 9 in the list (i.e. p.info=9): (head) 7 11 6 4 3 9 8 21 (tail)

7 11 6 4 3 13 9 8 21

Suppose a singly linked list of integers is given below and p is a reference to the node with value 9 in the list(i.e.p.info=9): (head)7 11 6 4 3 9 8 21(tail)

7 11 6 4 3 13 9 8 21

suppose a singly linked list if integers is given below and p is a reference to the node with value 9 in the list

7 11 6 4 3 13 9 8 21

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 15 in the list(i.e. p.info=15): (head) 7 11 6 4 3 15 8 12 (tail) What does the list look like after the following java code snippet is run? int x = 35; Node f=p.prev; //prev is a link to predecessor node Node q = new Node(x); //create new node with value x q.prev=f; q.next=p; f.next=q; p.prev=q;

7 11 6 4 3 35 15 8 12

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 15 in the list(i.e. p.info=15): (head)7 11 6 4 3 15 8 12(tail) What does the list look like after the following java code snippet is run?

7 11 6 4 3 35 15 8 12

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 15 in the list(i.e.p.info=15): (head)7 11 6 4 3 15 8 12(tail)

7 11 6 4 3 35 15 8 12

Suppose a singly linked list of integers is given below and p is a reference to the node with value 3 in the list

7 11 6 4 5 3 9 8 2

What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially(suppose T is empty before insertion): 7, 8, 4, 1, 3, 6, 9

7 4 8 1 6 9 3

7 8 26 44 13 23 57 98

7 8 13 23 26 44 57 98

What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially: 7, 8, 3, 1, 2, 5, 9

7, 3, 8, 1, 5, 9, 2

92 64 87 43 35 56 74 21 40

74 64 56 43 35 21 40 87 92

what is value of the Boundary Folding Hash Function if K = 43-65-76-7 and Tsize = 100?

82

What is the value of the Shift Folding Hash Function if K = 43-65-69-7 and TSize = 100?

84

What is the value of the Boundary Folding Hash Function if K = 43-57-69 and TSize = 100?

87

What is value of the Boundary Folding Hash Function if K = 43-57-69 and TSize = 100?

87

What is the value of the Boundary Folding Hash Function if K=45-65-79-8 and TSize=100?

88

what is the value of the boundary folding hash function

88

Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex H to the vertex T. What is the label of the vertex D when the shortest path from H to T is determined?

9

If the values of A, B, C and D are 2, 3, 4, and 5, respectively , manually calculate the value of the following postfix expression:

9

What is the value of the Shift Folding Hash Function if K = 43-65-76-7 and TSize = 100?

91

what is value of the Shift Folding Hash Function if K = 43-65-76-7 and Tsize = 100?

91

What is the value of Shift Folding Hash Function if the key K = 44-65-76-8 and TSize = 100?

93

What is the value of the Shift Folding Hash Function if the key K = 44-65-76-8 and TSize=100?

93

What is the value of the Shift Folding Hash Function if the key K=44-65-76-8 and TSize=100?

93

What is the value of the Boundary Folding Hash Function if K = 42-58-67 and TSize = 100?

94

What is value of the Boundary Folding Hash Function if K = 42-58-67 and TSize = 100?

94

what is the value of the Boundary Folding Hash Function if K = 42-58-67 and Tsize = 100?

94

What is the value of Shift Folding Hash Function if K = 45-65-79-8 and TSize=100?

97

Why do we need a tree data structure like the binary search tree?

A binary search tree is a very flexible data structure that allows a contiguous implementation and a very efficient run time for insertion and deletion.

What is a class?

A blueprint that defines an objects variables and methods.

Select the statement that is most correct.

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases.

Select the statement that is most correct. For a recursive method terminate there must be one or more steps For a recursive method terminate there must be one or more limit conditions There is no difference between a recursive method and a non-recursive method

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases.

Select correct statement about Run-length encoding.

A serious drawback of run-length encoding

Select correct statement about Run-length encoding.

A serious drawback of run-length encoding is that it relies entirely on the occurrences of runs.

Suppose that you have a directed graph representing all the flights that an airline files. What algorithm might be used to find the best sequence of connections from one city to another?

A shortest-path algorithm.

What is an object?

A software bundle of variables and related methods.

What is a constructor?

A special method that is called automatically whenever a new object is created. It prepares the object for use.

(1) Put the vertex X to H (2) Check if H is a Hamilton cycle the stop, else go to (3) (3) Consider the last vertex Y in H, if there is/are vertex(es) adjacent to Y, select the first adjacent vertex Z (by alphabet order) and put it to H. if there no adjacent vertex, remove Y from H and denote it as bad selection (so you do not select it in the same way again). Go to (2)

A, B, C, E, D, A

Given the graph G = (V,E) and X is a vertex of G. Suppose there exists at least one Hamilton Cycle for the graph. The following is a backtracking algorithm for finding the first Hamilton cycle from the vertex X:

A, B, C, E, D, A

Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex F. What are the correct order of

A, B, C, E, D, F

Assume in directed graph edge uv means "vertex v depends on vertex u". What is valid topological sort

A, B, D, C, E, F, G, H

Assume in directed graph edge uv means "vertex v depends on vertex u". What is valid topological sort of the graph shown below:

A, B, D, C, E, F, G, H

Suppose a graph G is given by the adjacency matrix below(see picture). Which of the following is the Hamilton

A, D, E, C, B, A

Suppose a graph G is given by the adjacency matrix below. Which of the followings is the Hamilton cycle?

A, D, E, C, B, A

Consider the following pseudocode: What is written to the screen for the input "GoodA***fter****Noo**n" ?

Adoretfoo

What is writen to the screen for the input "GoodA***fter****Noo**n"?

Adoretfoo

what is written to the screen for the input "GoodA***fter****Noo**n"?

Adoretfoo

Consider the follwing pseudocode: declare a stack of characters while(there are more characters in the word to read) What is writen to the screen for the input "GoodA**fter******Noo*n"?

Adretfoo

declare a stack of characters while(there are more characters in the word to read) {read a character if a character is ?*? then pop and write the poped character to screen else push the character into the stack} What is written to screen for the input ?GoodA**fter*****Noo*n??

Adretfoo

Which of the following data structure is linear type

All of above

Pushdown list means

All of the above

Pushdown list means:

All of the above

With respect to recursion, select correct statement

All of the others

A recursive method may be eliminated by using ∑∑.

All of the others.

Algorithms are applied to graphs:

All of the others.

In the array implementation of the queue, which operations require constant time?

All of the others.

What is a data structure?

An arrangement of data inside a computers memory or a disk.

In an array queue, data is stored in an _____ element.

Array

Why the code snippet below does not run? public class main{public static void main(String[] args){int[]a;}}....

Array "a" is not initialized.

Why the code snippet below does not run? public class Main {public static void main(String [] args) {int [] a; int n = 5; for(int i=0; i<n; i++) {a[i] = i; System.out.println(a[i]);} System.out.println();}}

Array ?a? is not initialized

Which of the following data structure can't store the non-homogeneous data elements?

Arrays

Which of the following data structure is linear data structure?

Arrays

Why must you use the key word "new" when creating an array?

Arrays in java are treated as objects.

In the linked list implementation of the stack class, where does the push method place the new entry on the linked list?

At the head

In the linked list implementation of the queue class, where does the insert method place the new entry on the linked list?

At the tail

Which of the following applications may use a stack?

Auxiliary data structure for algorithms

Select the statement that is most correct. Which of the following applications may use a stack?

Auxiliary data structure for algorithms.

Which of the following applications may use a stack?

Auxiliary data structure for algorithms.

Given a weighted graph below (See picture) and you are using the Dijstra algorithm to find the shortest path from the vertex B to the vertex F.

B, C, D, F

ch = top element of the stack S if ch is isolated then remove it from the stack and put it to E else select the first vetex Y (by alphabet order). which is adjacent to ch.push Y to S and remove the edge (ch.Y) from the graph

B, D, C, B, A, B

Which of the folloeings is the Euler cycle

B,A,D,B,C,B

Suppose you are using the LZW algorithm to encode the message AABAACAABD contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What string is denoted by code word (7)?

BA

Select the most correct statement about the complexity of selection sort

Both best and worst cases are 0(n^2)

Select the most correct statement about the complexity of selection sort

Both best and worst cases are O(n^2)

Select the most correct statement about the complexity of heapsort

Both best and worst cases are O(nlogn)

Select the most correct statement about the complexity of heapsort

Both the best and worst cases are O(nlogn)

Which traversal method is used in Adaptive Huffman tree?

Breadth First traversal

What graph traversal algorithm uses a queue to keep track of vertices which need to be processed?

Breadth-first search

What graph traversal algorithm uses a queue to keep track of vertices which needs to be processed?

Breadth-first search

... will visit nodes of a tree starting from the highest (or lowest) level and moving down (or up) level by level and at a level, it visits nodes from left to right(or from right to left)

Breath-First Traversal

____will visit nodes of a tree starting from the highest (or lowest) level and moving down (or up) level by level and at a level, it visits nodes from left to right(or from right to left).

Breath-First Traversal

will visit nodes of a tree starting from the highest (or lowest) level and moving down (or up) level by level and at a level, it visits nodes from left to right (or from right to left)

Breath-First Traversal

How do other parts of your program interact with objects?

By interacting with an objects methods

What is the result of decoding the string: 011100000101

CAABBCAB

Which of the following methods is used to collision resolution:

Chaining

Which of the following statement about Perfect Hash Functions are true:

Cichelli? method ...words && Cichelli? method ...search

Specify the statement that is most correct about a circular linked list

Circular linked list is a linked list in which the last node of the list points to the first

Specify the statement that is most correct about a circular linked list

Circular linked list is a linked list in which the last node of the list points to the first node in the list

Specify the statement that is most correct about a circular linked list.

Circular linked list is a linked list in which the last node of the list points to the first node in the list

The time factor when determining the efficiency of algorithm is measured by

Counting the number of key operations

When a method call is executed, which information is not saved in the activation record?

Current depth of recursion

When a method call is executed, which information is not saved in the activation record?

Current depth of recursion & Instances of classes.

Which of the following algorithms in graphs can be implemented by extending Depth First Search algorithm?

Cycle detection

What is the breadth-first traversal from the vertex D of a graph below? (visit nodes in ABC order if there are some nodes having the same selection ability)

D, C, B, F, A, E, G, H

What is output of breadth-first traversal from vertex D

D, C, F, B, G, A, E, H

Which of sentences about singly linked list are true:

Deleting a node ..&& On the average..&&There is no immediate

Select a correct statement about a singly linked list.

Deleting a node at the beginning of a list involves setting head to point to head.next

A method of a class is only accessible by classes that are defined within the same package with the class containing this method. How can such a restriction be enforced?

Do not declare the method with any access modifier

Select the statement that is most correct. Which of the following applications may use a stack?

Evaluating arithmetic expressions

What type of the hash functions that can be used in an English ∑Vietnamese dictionary?

Extraction

Which of the following name does not relate to stacks?

FIFO lists

In a binary search tree, all the nodes that are left descendants of node A have key values greater thanA; all the nodes that are A?s right descendants have key values less than (or equal to) A?

False

In all cases, nonrecursive implementation is faster recursive implementation

False

Which of the following statements about finding the shortest path are true

For label-correcting method, information of any ,The complexity of Dijkstras algorithm is O(|V|2) ,The complexity of Ford algorithm is O(|V||E|) fo

What us written to the screen for the input "Good**Morn**in***g"?

GoMg

declare a stack of characters while(there are more characters in the word to read) {read a character if a character is ?*? then pop the stack else push the character into the stack} while(the stack is not empty) pop and write the poped character to the screen What is written to screen for the input ?Good**Morn**in***g?

GoMg

The ..... algorithm can be used to schedule the final exams so that no student has two exams at the same time.

Graph coloring

Given a weighted graph below and you are using the Dijkstra algorithm to find the sortest path from the vertex H to the vertex T. What are the correct order of vertices selected into the set S until the vertex T is selected?(Each step a vertex with minimal current distance is selected into S).

H, A, B, D, T

Given a weighted graph below and you are using the Dijkstra algorthm to find the shortest path from the vertex H to vertex T. What are the correct order of vertices selected into the set S until the vertex T is selected? (Each step a vertex with minimal current distance is selected into S).

H, A, B, D, T

What is the correct definition of a hash function? (Select the best answer)

Hash function h(x) is a function which transforms a particular key x, (dai nhat)

What is the correct definition of a hash function? (Select the best answer)

Hash function h(x) is a function which transforms a particular key x, be it a string, number, record, or the like, into an index i = h(x) in the table T, where T[i] is used for storing an item having key x or its address

The Java Collections Framework contains a Map interface. An implementation of this interface is ∑

HashTable

What is the correct definition of a hash table?

Hast Table T is an (dai nhat)

Which algorithms have the complexity of O(n lgn)

Heap sort ..&& Quick sort in the best case

Which of the following statements about efficient sorting is true:

Heap sort...&& In heap sort...

Select (an) incorrect statement(s) about data compression.

Huffman algorithm can be only applied to text files.

Select incorrect statement about Data compression:

Huffman tree can be constructed bottom-up only.

Select incorrect statement about data compression.

Huffman tree can be only constructed bottom-up

Select incorrect statements about Huffman Coding:

Huffman tree...algorithm & Adaptive Huffman...

What does the searchKey variable do?

IT holds the value we are looking for.

If str denotes a String object with the string "73", which of these expressions will convert the string to the int value 73?

If str denotes a String object with the string

Which statements are true (select two):

In a singly-linked list there is ... + ...after ... O(1)

Specify the correct statement about chaining method for handling collision

In chaining, each positions of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys

Specify the most correct statement about chaining method of handling collision

In chaining, some positions of the table is associated with a linked list or chain of structures whose info

Specify the correct statement about coalesced chaining method for handling collision (select the best answer).

In coalesced hashing,...pos

Which of the following statement about Open Addressing are false:

In linear...&& Using quadratic...

Which of the following is true about linked list implementation of stack?

In push operation = False.

Consider open addressing method, select an incorrect statement.

In quadratic probing the offset from x is the square of the step number, so the probe goes to x, x+1, x+2, x+3, x+4, and so on.

Identify the data structure which allows deletions at both ends of the list but insertion at only one end.

Input-restricted deque

Which of the following Sorting algorithms have complexity of O( n ) in best case ?

Insertion sort

the array elements are ordered as 2 4 5 7 8 1 3 6 What algorithm can create this result?

Insertionsort.

See picture:

Integer "j" is not initialized.

Specify the correct implementation of pop() method of a stack of integers. This stack uses java.util.LinkedList for storing data and the end of the list is treated as the top of the stack. (Choose the most suitable one)

Integer pop() if (isEmpty()) return(null); return((Integer) pool.removeLast());

Specify the correct implementation of pop() method of a stack go integers. This stack uses java.util.LinkedList for storing data and the end of the list is treated as the top of the stack

Integer pop() {if(isEmpty()) return; return((Integer) pool.remove(pool.size()-1));

Specify the correct implementation of pop() method of a stack of Integers. This stack uses java.util.ArrayList for storing

Integer pop(){ if(isEmpty())return;

Specify the correct implementation of pop() method of a stack of Integers. This stack uses java.util.LinkedList for storing data and the end of the list is treated as the top of the stack.

Integer pop(){if(isEmpty()) return(null); return(Integer) pool.removeLast();}

Specify the correct implementation of pop() method of a stack of Integers. This stack uses java.util.ArrayList storing data and the end of the list is treated as the top of the stack.

Integer pop(){if(isEmpty()) return; return((Integer) pool.remove(pool.size()-1));

What is "peek"?

It allows the user to read the value at the top of the stack with out removing it.

Select the statement that is most correct. Suppose we are considering a doubly linked list which has at least 2 nodes. Wha does java code snippet below do? Node f = tail.prev; f.next=null; tail=f;

It deletes the last node.

Select the statement that is most correct. Suppose we are considering a doubly linked list and p is some node in the list which has successor node. What does the java code snippet below do? Node p1,p2; p1 = p.next; p2 = p1.next; p.next = p2; if(p2!=null) p2.prev=p;

It deletes the node after p.

Suppose we are considering a singly linked list and p is some node in the list which has successtor node.

It deletes the node after p.

Suppose we are considering a doubly linked list and p is some node in the list which has both predecessor and successtor nodes.

It deletes the node p.

Suppose we are considering a singly linked list and p is some node in the list which has both predecessor and successor nodes

It deletes the node p.

How is the constructor named?

It has the same name as the class it resides in.

Suppose we are considering a doubly linked list and p is some node in the list which has successor

It inserts new node with value x after the node p.

What kind of list is best to answer questions such as "What is the item at position n?"

Lists implemented with an array.

What is the worst-case time for binary search finding a single item in an array?

Logarithmic time

Which one of the following is an application of Stack Data Structure?

Managing function calls, The stock span problem, Arithmetic expression evaluation.

What do algorithms do?

Manipulate the data in data structures in various ways such as sorting.

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases.

Most Correct

Suppose we are considering a singly linked list which has at least 2 nodes. Select the most correct java code snippet that deletes the last node

Node f=head; while(f.next!=tail) f=f.next; f.next=null; tail=f;

that inserts new node with value x at the head of the list (the new node will be the first node in the list)

Node q = new Node(x); q.next = head; head = q;

Which of the following data structure is not linear data structure?

None of above

Using adjacency matrix representation for a graph of n vertices and m edges, what is the expected number of operations needed to loop through the graph to find down adjacent list of a known vertex?

O( n )

What is the complexity of inserting a node in a perfectly balanced tree for worst case?

O(lgn)

Node search(int x) {Node p = root; while (p!=null && p.info!=x) {if(x<p.info) p = p.left; else p=p.right;} return(p)} The complexity of this algorithm is

O(log2n)

The complexity of Binary search algorithm is

O(n log n)

the complexity of merge sort algorithm is

O(n log n)

Basically, the complexity of inserting new element before a given node in the middle of a singly linked list is

O(n)

Basically, the complexity of inserting new element before a given node in the middle of a singly linked lists is

O(n)

Given a search() method in a binary search tree: Node search(int x) { Node p = root; while(p!=null && p.info != x){if(p<p.info) p = p.left; else p=p.right;} return(p);} The complexity of this algorithm is:

O(n)

The complexity of linear search algorithm is

O(n)

basically, the complexity of fiding the position of the minimum value in a doubly-linked list of integer numbers is

O(n)

basically, the complexity of inserting a node after given node in a singly linked lists is

O(n)

the complexity of counting the number of items

O(n)

while(p!=null && p.info != x)

O(n)

The complexity of Bubble sort algorithm is

O(n2)

the complexity of merge sort is

O(nlog2n)

In the worst-case mergesort is

O(nlogn)

What is the worst-case time for bubble sort to sort an array of n elements?

O`(n^2)`

Specify the correct implementation of pop() method of a stack. This stack uses java.util.ArrayList for storing data and the end of the list is treated as the top of the stack

Object pop() {if(isEmpty()) return(null); return(pool.remove(pool.size()-1));}

A properties of queue is ___________ can be accessed at once.

Only one item

A property of a stack is _________ can be accessed at once

Only one item

I have implemented the queue with a linked list, keeping track of a front node and a rear node with two reference variables. Which of these reference variables will change during an insertion into a NONEMPTY queue?

Only rear changes

In all cases, nonrecursive implementation is faster recursive implementation.

false

In the array list, poping is executed in O (lgn) to the worst case.

false

in a singly-linked list, there is no efficient way to insert a node before a given node in the middle or at the end of the list

false

linked lists are best suited

for relatively permanent collections of data

Linked lists are best suited

for relatively permanent collections of data.

x = 7; y = 4 * ++x; z = 5 * x--;

x = 7, y = 32, z = 40

Which data structure allows deleting data elements from front and inserting at rear

Queues

Which data structure allows deleting data elements from front and inserting at rear?

Queues

One difference between a queue and a stack is:

Queues use two ends of the structure; stacks use only one.

Which of the following Sorting algorithms use Divide and Conquer strategy?

Quick sort

Which of the following sorting algorithm is of divide-and-conquer type

Quick sort

Which of the following sorting algorithm is of divide-and-conquer type?

Quick sort

bitRadixsort() can be improved by implementing array , One of techniquesradix sort uses is by looking at each

Radix sort

Which of the following data structure store the non-homogeneous data elements?

Records

long [] arr is; an example of:

Referencing an array.

Which of the following statements about Run-Length Encoding are False:

Run-Length encoding cannot be applied to text files.

Specify the reason for data compression (select the best answer)

Saving data storage

Specify the reason for data compression (select the best answer):

Saving data storage

Elements of an array are stored _______ in memory

Sequentially

Which of the following statements about efficient sorting is false

Shell sort divides the original array into physical subarrays, s

In a _____every element contains some data and a link to the next element, which allows to keep the structure

Singly linked list

Which of the following data structures can be used to implement Huffman Coding ?

Singly linked list, Priority queue,Doubly linked list.

Select correct statements about Linked List:

Skip lists .. && The efficiency..

What is the value of the postfix expression 6 3 2 4 + - *:

Something between -15 and -100

Arrays are best data structures

Sorry, we couldn't play that audio. Try checking your language settings or send us some feedback if this happens frequently.

_________ is the way you groups things together by placing one thing on top of another and then removing things one at a time from the top

Stack

Pushdown list means:

Stack , Queue, Linked list

Select incorrect statement about Recursion:

The anchor or ground case allows for the construction of new objects out of basic elements or

When is insertionsort a good choice for sorting an array?

The array? size is not large .

Select the most correct statement about the complexity of bubble sort *

The best case is 0(n). and the worst case is 0(n~2)

Select the most correct statement about the complexity of insertion sort

The best case is 0(n). and the worst case is 0(n~2)

Select the most correct statement about the complexity of bubble sort

The best case is O(n), and the worst case is O(n^2)

Select the most correct statement about the complexity of insertion sort

The best case is O(n), and the worst case is O(n^2)

select the most correct statement about the complexity of bubble sort

The best case is O(n), and the worst case is O(n^2)

select the most correct statement about the complexity of insertion sort

The best case is O(n), and the worst case is O(n^2)

Select the most correct statement about the complexity of quicksort

The best case is O(n), the average case is O(nlogn),and the worst case is O(n^2)

When converting a method from a recursive version into an iterative version

The brevity of program formulation lost. However, the brevity may not bean issue in Java , Program clarity can be diminished

Specify the correct statement about open addressing method for handling collision

The collision ... hashed

We implement the stack as a singly linked list and use AddtoHead() method of the linked list to implement push() method. A top pointer of the stack is ∑

The head reference of the singly linked list

Which of the following concepts of tree are true

The height of a nonempty tree is the maximum level of node ,The level ofa node is the length of the path from the root to the node plus 1,The level ofa node must be between 1 and height of the tree

In the linked list version of the Bag class an instance variable manyNodes is used to keep track of how long the linked list is. Why not just make a call to the IntNode method listLength()?

The listLength() method is O(n) and the alternative is O(1).

Which of the following about stack are true:

The most top element is the latest added element

What is the number of comparisons and swaps in the best case for creating a heap using top down method (William? method)?

The number of comparisons is n ∑1 and swaps is zero.

Which of the following statements about Merge sort method are incorrect?

The number of recursion calls depends on every case (best, average, and worst).

Select incorrect statement about skip list:

The number of reference fields indicates the level of each node, and the number of levels is maxLevel = `[lgn]`+ 1

What is the goal in designing an external search algorithm?

The primary goal is to minimize the number of disk accesses.

What evolved from the 2-3-4 tree?

The red-black tree.

To delete a node in a binary search tree that has two children, the deletion by merging method requires to find what node?

The rightmost node of the left subtree of the deleted node.

Consider the following function: What will happen if the statement fun(33); is run?

The run-time stack overflows, halting the program

In a real computer, what will happen if you make a recursive call without making the problem smaller?

The run-time stack overflows, halting the program

void fun(int n){if(n>0) {System.out.print(" "+ n%5); fun(n); } } What will happen if the statement fun(33): is run?

The run-time stack overflows, halting the program

Suppose that obj is an Object variable and that it refers to an Integer object. If s is a String variable, then which statement is correct about the assignment "s = (String) obj;"?

The statement will compile, but there will be a run-time exception.

In a circular singly linked list, we can use only one permanent reference, the tail.The familiar reference, the head, is:

The successor of the tail

What is the big O time complexity to search an AVL tree? How about insertion and deletion?

The time complexity to search an AVL tree is O(log n). It's insertion and deletion functions also have a time complexity of O(log n).

Which of the following statements about efficient sorting is false

The worst case is when the bound divides an array ,The best case of quicksort happens when bound is

Entries in a stack are "ordered". What is the meaning of this statement?

There is a first entry, a second entry, and so on.

In a single method implementation, how many recursive calls can be used?

There is no fixed maximum number.

A chained hash table has an array size of 1024. What is the maximum number of entries that can be placed in the table?

There is no maximum

Consider the following prefix codes of symbols: V: 10

They are not acceptable.

In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the tree for efficiency. These special pointers are called

Thread

What is the primary purpose of a constructor?

To initialize each object as it is declared

Consider the following pseudocode: declare a queue of characters while(there are more characters in the word to read)

ToDay

Consider the follwing pseudocode: declare a queue of characters while(there are more characters in the word to read) What is writen to the screen for the input "HowAre***You**To***Day"?

ToDay

What is written to the screen for the input "HowAre**YouTo***Day" ?

ToDay

what is written to the screen for the input "HowAre***You**To****Day"?

ToDay

Which of the following methods are used to traverse a tree without using anystack or threads:

Traversal through tree Transformation

The operation of visiting each element in the list exactly once is known as

Traverse

The operation of visiting each element in the list exactly once is known as

Travese

To represent hierarchical relationship between elements, which data structure is suitable?

Tree

Which of the following statement about the Tree Traversal is false

Tree traversal..time && Postorder tree

35, 22, 39, 12, 27, 37, 24, 32

True

A recursive method is a method that invokes itself directly. For a recursive

True

A, B, C, E, D, A

True

An object can be saved in a life if its class type is stated, If the vectors capacity is greater than its size, then a new elem

True

D, C, B, A, E, G, F, H

True

For a binary tree with n nodes, there are n! different traversals, The complexity of searching depends on the shape of the tree and the,Breath-First traversal

True

If hash function transforms different keys into different numbers, it iscalled a perfect hash function

True

In Huffman coding, both the sender and receiver must have a copy of the same code in order for the decoded file to match the encoded file.

True

Select the statement that is most correct. Which of the following applications may use a stack?

Undo sequence in a text editor.

Which of the following strategies fit to Binary Search trees that only have some elements constantly accessed?

Use Self-Restructuring tree

What is a primary difference between an array and a Vector from Java's Class Libraries:

Vectors grow automatically as needed.

Which call will resulf in the most recursive calls?

fun(-1012)

Consider the following function: int fun(int n) Which call will result in the most recursive calls?

fun(-1012);

Which call will result in the most recursive calls?

fun(-1012);

int fun(int n) {if(n<0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n-2)); } Which call will result in the most recursive calls?

fun(-1012);

int fun(int n) {if(n<0) return(fun(-n); else if(n<5) return(2); else return(n*fun(n/2));} Which call will result in the most recursive calls?

fun(-1012);

return(n*fun(n/2)); Which call will result in the most recursive calls?

fun(-1012);

void fun(int n) {if(n < 0) {System.out.println("-"); fun(-n); } else if(n<10) System.out.println(n); else {fun(n/10); System.out.println(n%10); } } Which call will result in the most recursive calls?

fun(-1023)

Specify the most correct statement about chaining method for handling collision

in chaining, some positions of the table is associated with a linked list or chain of structure whose info fields store keys or references to keys

Depth-first traversal can not be implemented if not using stack

incorrect

What is an array?

What is an array?

The Average case occur in linear search algorithm

When Item is somewhere in the middle of the array

Which of the following can be executed in constant time O(n)

When deleting a node of a singly linked list in the average case , in the worst case

In 20-element skip list, the node in position 3 points to the node in position 7

incorrect

Morris? algorithm does not temporarily change tree structure.

incorrect

The search time is O (lgn) in the worst case.

incorrect

The keyword implements is used to specify that a class inherits from an interface The operation for adding an entry to a stack is traditionally called:

isEmpty()-check empty, enqueue(el)-put

Can two different classes contain methods with the same name?

Yes, this is always allowed

Value of the first linked list index is _______

Zero

Select the statement that is most correct

a recursive method is method that invokes itself directly or in directly. For?

A connected graph T without any cycles is called

a tree graph & free tree & a tree

Node p1,p2; p1 = p.next; p2 = p1.next; p.next = p2; if(p2!=null) p2.prev=p;

it deletes the node after p.

The most common algorithm to apply when such collisions occur is to simply put the new item in the next available component. What is the name of this coliision resolution algorithm?

Linear probing

Each entry in a linked list is called a

Link

Why multi-way search trees are suitable for external search?

Multi-way search trees have better disk utilization and has a smaller amount of disk accesses

In the linked-list version of the Queue, which operations require linear time for their worst-case behavior?

None of the others

Which of the following statement about spanning tree is false

None of the others

Which of the following statement about the Graph is true

None of the others

Which of the statements about Ziv-Lempel Code are False.

None of the others

In the array version of the Stack class, which operation requires linear time for their worst case?

None of the others.

When a method call is executed, which information does its activation record contain?

None of the others.

Which of the following statement about spanning tree is false:

None of the others.

Which of these operations are likely to have a constant time for worst-case in the linked lists?

None of the others.

Which of these operations are likely to have a constant time for worst-case in the singly linked lists?

None of the others.

" What is number of comparisons in the worst case for mergesort to sort an array of n elements ? "

O ( ` n `lg` n`)

Basically, the complexity of finding the position of the minimum value in a doublylinked list of integer numbers is .....

O( n )

A variable P is called pointer if

P contains the address of an element in DATA.

Which operation is used in DSW Algorithm:

Rotation

In a linked list, the tail node is introduced for performance purpose only.

True

In a singly-linked list every element contains some data and a link to the next element, which allows to keep the structure

True

In a singly-linked list there is no efficient way to insert a node before a given node in the middle of the list (the action is considered efficient if it's complexity is 0(1)).

True

In a singly-linked list we can insert a node after a given node with time complexity 0(1)

True

In a singly-linked list, there is no efficient way to insert a node before a given node in the middle or at the end of the list, but we can insert a node after a given node or at the beginning of the list with time complexity O(1)

True

In shift folding method, the key is usually divided into even, The boundary folding method is applied to number data

True

In the array implementation, enqueuing can be executed in constant time O(1)

True

Integer pop(){ if(isEmpty) return(null); return((Integer)pool.remove(pool.size()-1)); }

True

Object dequeue() {if (isEmpty()) return(null); return(pool.remove(0));}

True

Run length encoding is a lossless compression method in which repeated occurrences of a symbol are replaced by one occurrence of the symbol followed by the number of occurrences

True

Run-length encoding is very efficient for text file in which only blank character has a tendency to be repeated without using any technique

True

Subclasses or derived classes inherit the fields... , An abstract datatype can be part of a program in the form of an interface.

True

The keyword implements is used to specify that a class inherits from aninterface.

True

The recursive version increases program readability, improves self-documentation and simplifies coding

True

void enqueue(Object x){Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else {tail.next = p; tail = p;}}

True

void inOrder(Node p){ if(p != null){ inOrder(p.left); visit(p); inOrder(p.right);} }

True

void push(Integer x){ Node p = new Node(x); p.next = head; head=p; }

True

The node which is deleted from the list will ... e garbage collection, Deleting a node at the end of...ant time O(1), Processing for adding a node tothe end of list includes six steps

True about Doubly linked list

The complexity of sequential Coloring algorithm is O(|V|2) ,Sequential Coloring algorithm establishes the sequence of

True about Graph coloring

The Java implementation of the stack is potenti, Stack can be implemented by linked list

True about Stack

The most top element is the latest added element , Operations of stack based on Last in First out structure.

True about Stack

Deleting a node at the beginning of th ...time O(1) - On the average,delete operatio... O(n) steps, There is no immediate access to the predecessorof any node in list

True about singly linked list

The height of a nonempty tree is the maximum level of node ,The level ofa node is the length of the path from the root to the node plus 1,The level ofa node must be between 1 and height of the tree

True about tree

In an array queue, data is stored in an _____ element

array

which of the following applications may use a stack?

auxiliary data structure for algorithm

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more

base cases

Why is the constructor of the LinkedList class empty?

bc...of the LinkedList class is ...constructor of the LinkedList class.

Why is the constructor of the LinkedList class empty

because initialization of data members of the LinkedList class is performed by the constructor of the LinkedList class

Why is the constructor of the LinkedList class empty?

because initialization of data members of the LinkedList class is performed by the constructor of the LinkedList class

Why is the constructor of the LinkedList class empty?

because initialization of data members of the LinkedList class is performed by the constructor of the LinkedList class.

The size of a structure can be determined by a. size of variable name b. size of (struct tag)

both a and b

In a graph if e=(u, v) means

both b and c

In a graph if e=(u, v) means

both b and c (e begins at u and ends at v va u is processor and v is successor)

select the most correct statement about the complexity of selection sort

both best and worst cases are O(n^2)

A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

both of them

which of the followings is the Euler cycle?

c,b,a,b,d,c

In the circular array version of the Queue class, which operations require O(n) linear time for their worst-case behavior

clear() && enqueue() when the capacity has been reached

1 0 1 1

correct

4 9 9

correct

5 100 5

correct

A reorganization of the file is avoided by using extendible hashing if the directory overflows.

correct

A singly linked list is a node that has a link only to its successor in this sequence

correct

Breath-First traversal is implemented using queue

correct

For a binary tree with n nodes, there are n! different traversals.

correct

In Java, the extends clause is used to specify inheritance

correct

In shift folding method, the key is usually divided into even parts of some fixed size plus some remainder and added

correct

Inserting a new node at the end of the singly linked list without tail field requires O( n ) steps.

correct

Integer "j" is not initialized.

correct

Interfaces can extend any number of other interfaces.

correct

It removes the first element of the list

correct

Recursion is always more efficient than loops.

correct

The boundary folding method can not be applied to string data.

correct

The characteristic feature of extendible hashing is the organization of the index, which is expandable table.

correct

The complexity of searching depends on the shape of the tree and the position of the node in the tree

correct

The default modifier means that a method or a field is accessible to derived classes.

correct

for (int i=0, j=100; i < j; i++, --j) {;}

correct

jikstra's shortest path algorithm can be applied to undirected graph.

correct (chon all)

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The current capacity is 42. Where does the insert method place the new entry in the array?

data[12]

To delete a dynamically allocated array named `a`, the correct statement is

delete a

To delete a dynamically allocated array named `a`, the correct statement is

delete a;

The operation for removing and returning the end element of the queue is traditionally called:

dequeue

Which of the following is two way list

doubly linked list

In a graph if e=(u, v) means

e begins at u and ends at v & u is processor and v is successor

Insertion sort is applied to small portions of an array, Mergesort can be made more efficient by replacing

efficient sorting

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

elementary items & atoms & scalars

The operation for adding an entry to a queue is traditionally caled:

enqueue

The operation for adding an entry to a queue is traditionally called:

enqueue

what is written to the screen for the input "FileComp***ress*ion**"?

iserCeliF

Suppose we are considering a doubly linked list and p is some node in the list with has successor node. What does the java code snippet below do? Node p1, p2; p1=p.next; p2=p1.next; p.next=p2; if(p2!=null) p2.prev=p;

it deletes the node after p

void fun() {if(isEmpty)) return; if(head==tail) head=tail=null; else {Node p1, p; p1=null; p=head; while(p!=tail){p1=p;p=p.next;} p1.next=null; tail=p1;}} Specify the correct statement about the fun() method in the code above

it removes a node at the end of the list

void fun(){if(isEmpty()) return; if(head==tail) head = tail = null; else head = head.next;} specify the correct statement about the fun() method in the code above

it removes the first element of the list

Suppose the h(n) function is defined on the set of integer numbers as below. For the call h(3).how many calls to h will be made, including the original call? int h(int n) {if(n==0 |

n==1) return(1); else return(h(n-1)+h(n-2)); } | 3

Suppose the h(n) function is defined on the set of integer numbers as below. For the call h(3), how many calls to h will be made, including the original call? int h(int n) {if(n==0 |

n==1) return(1); else return(h(n-1)+h(n-2));} | 5

A chained hash table has an array size of 512. What is the maximum number of entries that can be placed in the table?

none other choices

Which of the following case does not exist in complexity theory

null case

What is the worst-case time for finding an element in a Binary tree?

o(n)

What is written to the screen for the input "Go**od**Mor*ni*ng*Sir" ?

oGdorig

What is written to the screen for the input "Go**od**Mor*ni*ng*Sir"?

oGdorig

what is written to the screen for the input "Go**od**Mor*ni*ng*Sir"?

oGdorig

declare a stack of characters while(there are more characters in the word to read) {read a character if a character is ?*? then pop and write the poped character to the screen else push the character into the stack} What is written to screen for the input ?Go**od**Mor*ni*ng*Sir?

oGdoring

What is written to the screen for the input " Go**odMorn**in***g" ?

oGnrnio

what is written to the screen for the input "Go**odMorn**in***g"

oGnrnio

Suppose that obj is an Object variable and s is a String variable. Which of the following statements is a correctly-compiling widening conversion? Don't worry about possible run-time exceptions.

obj = s

Which of the following statement is false

pointers store the next data element of a list

The operation for removing an entry from a stack is traditionally called:

pop

The operation for removing and returning the top element of the stack is traditionally called:

pop

Which of the following stack operations could result in stack underflow?

pop

the operation for removing and returning the top element of the stack is traditionally called

pop

void preOrder(Node p){ if(p = null) { visit(p); preOrder(p.left); preOrder(p.right); } }

pre-order traverse algorithm

A heap implemetation is an excellent demonstration for a .......

priority queue

What kind of methods of a class can be called by methods which is belong to another class?

public methods

The operation for adding an entry to a stack is traditionally called:

push

declare a stack of characters while(there are more characters in the word to read) {read a character if a character is ?*? then pop the stack else push the character into the stack} while(the stack is not empty) pop and write the poped character to the screen What is written to screen for the input ?Good**Mor*ni**ngSir?

risgnMog

A graph that has neither felf-loop nor parallel edges are called ...

simple graph

In a??.every element contains some data and a link to the next element, which allows to keep the structure

singly linked list

in a ___ every element contains some data and a link to the next element, which allows to keep the structure

singly linked list

Binary search algorithm can not be applied to

sorted binary trees

Binary search algorithm cannot be applied to

sorted binary trees

binary search algorithm cannot be applied to

sorted doubly linked list

Suppose temp refers to some node in a doubly linked list. What boolean expression can be used to check whether temp refers to the first node of the list?

temp.previous == null

select the most correct statement about the complexity of insertion sort

the best case is O(n), and the worst case is O(n^2)

Select the most correct statement about the complexity of insertion sort

the best case is O(n), worst case is O(n^2)

Each array declaration need not give, implicitly or explicitly, the information

the first data from the set to be stored

What happens when you push a new node onto a stack

the new node is placed at the front of the linked list

when representing any algebraic expression E which use only binary operations in a 2 tree

the variable in E will appear as external nodes and operations in internal nodes

when representing any algebraic expression E which uses only binary operations in a 2-tree

the variable in E will appear as external nodes and operations in internal nodes

In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the tree for efficiency. These special pointers are called

thread

If the two stacks are implemented on a single array, the overflow occurs at

top1=top2 && top1=top2-1

The depth-first search algorithm for a graph will

travel all possible paths from a vertex to see if it can find the destination before it moves on to the adjacent vertices

35, 22, 39, 12, 27, 37, 24, 32

true

4, 6, 10, 2, 9, 1, 3, 7, 5, 11

true

Expression trees do not use parentheses.

true

Hash function is function that can transform a particular key (K) (a string, number or record) into an index in the table used for storing items of the same type as K.

true

In data compression, no special punctuation is required to separate two codewords in a coded message

true

In the array implementation of queue, enqueuing can be executed in constant time O(1)

true

Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system.

true

Stack can be implemented by linked list.

true

The Java implementation of the stack is potentially fatal

true

The height of a nonempty tree is the maximum level of a node in the tree

true

The level of a node is the length of the path from the root to the node plus 1

true

The level of a node must be between 1 and height of the tree.

true

The recursive version increases program readability, improves self-documentation and simplifies coding

true

The recursive version increases program readability, improves self-documentation and simplifies coding.

true

The return address is address of the caller? instruction immediately following the call.

true

The run-time stack overflows, halting the program

true

Using Polish notation, all expressions have to be broken down unambiguous into separate operations and put into their proper order

true

With respect to the hashing technique using for information hiding, the more complex the hashing function, the better it is

true

b, d, c, b, a, b

true

enqueue(el) ∑Put the element el at the end of the queue.

true

firstEl() ∑Return the first element in the queue without removing it.

true

fun(-1023)

true

in a linked list, the tail node is introduced for performance purpose only

true

in a singly-linked list every element contains some data and a link to the next element. which allows to keep the structure

true

in a singly-linked list ther is no efficient way to insert a node before a given node in the middle of the list

true

in a singly-linked list we can insert a node after a given node with time complexity O(1)

true

in a singly-linked list, there is no efficient way to insert a node before a given node in the middle or at the end of the list, but we can insert a node after a given node or at the beginning of the list with time complexity O(1)

true

in chaining, some positions of the table is associated with a linked list or chain of structures

true

in coalesced hashing, the linked list is created inside the hash table. each position pos in the table contains 2 fields: info and next

true

isEmpty() ∑Check to see if the queue is empty.

true

it deletes the node p

true

it inserts new node with value x before the last node

true

it throws nullPointerException

true

keeping track of previous choices (as in backtracking)

true

n >= 0 && n<15

true

the tree is full but not complete

true

Binary Trees can be implemented as arrays

true about binary

The search process of Binary Search Tree takes O( n ) time in the worst case.

true about binary

For label-correcting method, information of any label can be changed during application of method

true about finding

declare a queue of characters while(there are more characters in the word to read) {read a character if a character is ?*? then dequeue the queue else enqueue the character into the queue} while(the queue is not empty) dequeue and write the dequeued character to the screen What is written to screen for the input ?HowAre***You**To***Day??

uToDay

while(there are more characters int the world to read){ read a character if a characteris '*' then dequeue the queue... dequeue and write the dequeued characte to the screen what is written to the screen for the input "HowAre***You***To***Day"?

uToDay

suppose we are implementing a queue using a singly linked list where the end of the list is treated as the end of the queue

void enqueue(object x) {Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else {tail.next = p; tail = p;}}

Specify the correct implementation of in-order traverse algorithm for binary trees.

void inOrder(Node p) { if(p != null) {inOrder(p.left);...

specify the correct implementation og pre-order traverse algorithm for binary trees

void preOrder(Node p) { if(p != null) {visit(p); preOrder(p.left); preOrder(p.right);}}

specify the correct implementation of push() method of a stack

vois push(integer x) {Node p = new Node(x); p.next = head; head=p}

To implement an AVL tree,a concept balance factor is introduced(ball = height(right)-height(left). suppose an AVL...: 5, 2, 6, 1, 3, 4

-1

using huffman encoding, what is the code for character E

001

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% Using Huffman encoding, what is the code for character C?(Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

01

Using Huffman encoding. what is the code for character C?(Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

01

What is the result of the breadth first traverse of the binary search tree T. after inserting the follwing keys into the tree sequentially(suppose T is empty before insertion): 7,8,3,1,2,5,9

7,3,8,1,5,9,2

What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially(suppose T is empty before insertion) 7,8,4,1,3,6,9

7,4,8,1,6,9,3

Suppose a multigraph G is given by the adjacency matrix below. Which of the followings is the Euler cycle?

A, B, C, B, D, A

which of the following is the Hamilton cycle?

A, B, C, D, E, C, A | A, B, D, E, C, A

Suppose a graph G is given by the adjacency matrix below. Which of the followings is the Hamilton cycle?

A,B,C,E,D,A

Suppose you are using the LZW algorithm to encode the message AABCADAB contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What string is denoted by code word (5)7

AA

Suppose you are using the LZW algorithm to encode the message AABCADAB contents of the dictionary at the beginning of encoding are: (1)A (2) B (3) C (4) D What string is denoted by code word(5)?

AA

suppose you are using the LZW algorithm to encode the message AABCADAB contents of the dictionary at the beginning of encoding are

AA

Using the Hulfman code tree below. What is the result of decoding the string: 1100000001100

AABBBCAB

Suppose you are using the LZW algorithm to encode the message AAABCADAB contents of the dictionary at the beginning of encoding are:

AB

Using the Huffman code tree below. What is the result of decoding the string:

ABBCD

Using the Huffman code tree below. What is the result of decoding the string: 10000010011?

ABBCD

The post order traversal of a binary tree is DEBFC. Find out the pre order traversal

ABDECF

Tree balancing can be performed locally after an element is inserted into or deleted from the tree using

AVL tree.

The reason for using pointer is ... Choose the false option from the following sentences

Accessing arrays or string elements

pop and write the poped character to the screen what is written to the screen for the input "GoodA**fter*****Noo*n"?

Adretfoo

push the character into the stack

Adretfoo

A stack can be implemented using .....

All of the others

Two algorithms, used for finding a minimum spanning tree, are Kruskal and Dijkstra. Which algorithm uses the cycle detection method?

All of the others

Which of the following problems may use the recursion technique?

All of the others

Which operation on a linked list will take O( n ) time for the worst case?

All of the others

Definition of a balanced tree: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa."

False

Which of the following applications may use a queue?

Keeping track of local variables at run time.

______ form of access is used to add and remove nodes from a stack

LIFO

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is linear probing. How the hash table looks like after inserting the following keys sequentially?

(3)

class A{int x; A(int x1) {x=x1;}} public class Main {static void foo(A t) {t.x += 100; System.out.print(t.x + ? ?);} public static void main(String [] args) {A h = new A(5); System.out.print(h.x + ? ?); foo(h); System.out.print(h.x + ? ?); System.out.println();}}

5 105 5

what is the breadth-first traversal of a tree below after deleting the node 2 by merging

5, 1, 7, 4, 6, 8, 3

What is the result of the breadth first traverse of the binary search tree T, after inserting following keys into the tree sequentially (suppose T is empty before insertion): 6, 7, 3, 1, 2, 5, 8

6, 3, 7, 1, 5, 8, 2

Consider the following function: void quiz(int n){if(n>1){quiz(n/2);quiz(n/2);}System.out.print("* ")}; How many asterisks are printed by the function call quiz(5)?

7

How many asterisks are printed by the function call quiz(5)

7

What is the value of the Shift Folding Hash Function if K = 45-65-79-8 and TSize = 100

97

What is the value of the Shift Folding Hash Function if k = 45-65-79-8 and TSize = 100

97

What string is denoted by code word (7)?

BA

Name 5 data types

BLASH: binary trees, linked lists, arrays, stacks, hash tables

State True or false: Definition of a ballanced tree: "a balanceed tree is one whose root has many more left descendents than right descendants or vice versa."

False

Basically, the complexity of inserting a node after a given node in a singly linked lists is .....

O( n )

In the selection sort algorithm applied to an array of n elements, how many times are the array elements moved in the worst case ?

O( n )

The complexity of Binary search algorithm is

O(log n)

If hash function transforms different keys into different numbers, it is called a perfect hash function.

true

fun(-1012)

true

The complexity of Dijkstra? algorithm is `O(|V|^2)`

true about finding

Sequential Coloring algorithm establishes the sequence of vertices and a sequence of color before coloring them.

true about graph

The complexity of sequential Coloring algorithm is `O(|V|^2)`

true about graph

The Depth First Search for graph traversal generates a spanning tree if original graph is connectivity and undirected.

true neu co all thi chon

Consider the following pseudocode:

4

Consider the list of eight integers below: 6,4,10,11,9,3,7,5 What is the list after it has just been partitioned by the first step of quicksort and a pivot value....

3,4,6,5,9,11,7,10

Consider the AVL tree below. What is the breadth first traversal of the tree after inserting a node with value 24?

35, 22, 39, 12, 32, 37, 27, 24,

Given a raw message 'BBBUUUUBBBUUBBBBBUU' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

3B4U3B2U5B2U

Given a raw message 'FFFOOOOFFFOOFFFFFOO'

3F4O3F2O5F2O

Given a raw message 'BBBBQQQQBBBQQBBBBBQQ' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

4B4Q3B2Q5B2Q

Given a raw message 'FFFF0000FFF00FFFFF00' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

4F403F205F20

Given a raw message 'FFFFOOOOFFFOOFFFFFOO' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

4F4O3F2O5F2O

given a raw message 'FFFFOOOOFFFOOFFFFFOO'

4F4O3F2O5F2O

Given a raw message 'XXXXUUUUUXXXXUUXXXXXUU' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

4X5U4X2U5X2U

(In a tree the height of root is 1, and in a full binary tree every node other than the leaves has two children).

5

Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex B. What is the label of the vertex D when the shortest path from A to B is determined?

5

What is the breadth-first traversal of a tree below after deleting the node 2 by copying?

5 1 7 4 6 8 3

See picture:

5 100 100

What is the output of the code snippet below Class A {int x; A(int x){x = x1;}}?

5 105 105

6, 4, 10, 11, 9, 3, 7, 5 What is the list after it has just been partitioned by the first step of quicksort and a pivot value is chosen as the first element of the list

3, 4, 5, 6, 9, 11, 7, 10

int fun(int n) {if(n<0) return(fun(-n); else if(n<5) return(2); else return(n*fun(n/2));} What is the value of fun(5)

10

return(n*fun(n/2)); What is the value of fun(5)?

10

Given a weighted graph below (see picture) and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex F

11

Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex F. What is the label of the vertex E when the shortest path from A to F is determined?

11

What is maximum number of activation records ( including its caller ) in runtime stack when calling TriangularNumber(10)

11

Consider the list of ten integers below: 8, 5, 11, 12, 3, 10, 2, 4, 9, 6 What is the list after the first two iterations of the large loop in a selection sort?

2, 3, 11, 12, 5, 10, 8, 4, 9, 6

What is the list after the FIRST TWO interations of the large loop in a selection sort?

2, 3, 11, 12, 5, 10, 8, 4, 9, 6

int [] a = {6, 3, 9, 10, 8, 2, 7, 5};

2, 3, 5, 6, 8, 10, 7, 9

8, 5, 11, 12, 4, 10, 2, 5, 9, 6 What is the list after the first two iterations of the large loop in a selection sort?

2, 4, 11, 12, 5, 10, 8, 5, 9, 6

Consider the list of ten integers below: 16, 5, 2, 11, 10, 8, 12, 3, 8, 6 What is the list after the first two steps of insertion sort? (sorting from smallest to largest)

2, 5, 16, 11, 10, 8, 12, 3, 8, 6

What is the breadth-first traversal of a tree below after deleting the node 5 by merging?

2,1,4,3,7,6,8

what is the breadth-first traversal of a tree below after deleting the node 5 by merding?

2,1,4,3,7,6,8

The following is the main part of selection sort pseudocode: Consider the list of ten integers below: 8,5,11,12,4,10,2,5,9,6 What is the list after first two iterations of the large loop in a selection sort? (sorting from smallest to largest)

2,4,11,12,5,10,8,5,9,6

How many parts are there in a declaration statement?

3

What is a deque?

A double-ended queue. You can insert items and either end & delete items from either end.

The reason for using pointer is ...

Accessing arrays or string elements

What is wrapping around? When is it useful? What is created that must be fixed?

Wrapping around allows the user to fill in new items in the queue at index zero, assuming that the queue is empty at index zero. This creates a broken sequence (the items in the queue are in two different sequences in the array).

How does the mail sorting analogy apply to the priority queue?

You insert a letter from the postman into your pile of pending letters according to priority. The higher the priority the higher the position in the pile.

The size of a structure can be determined by

a. size of variable name + b. size of (struct tag)

What member function places a new node at the end of the linked list?

appendNode()

Which of the following case does not exist in complexity theory

Null case

Explain how you would create an algorithm that matches delimiters on the stack. Include errors in your explanation.

1. Read the characters from a string one at a time.

The post order traversal of a binary tree is DEBFC Find out the pre order traversal

ABDECF

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.

D

Which of following statements are true:

If the vector? capacity .. && An object can be saved in a..

What is the difference between a stack and a queue?

In a queue the first item inserted is the first to be removed (FIFO). In a stack the last item inserted is the first to be removed (LIFO)

How is "peek" different in a queue?

It "peeks" at the value of the item at the front of the queue without removing it as opposed to the last value in a stack.

form of access is used to add and remove nodes from a stack

LIFO

Explain LIFO

Last-In-First-Out. A stack is a LIFO storage mechanism because the last item inserted is the first one to be removed.

Each entry in a linked list is called a _______

Link

Which of the following data structure is non-linear type?

None of above

Which of the following is not the required condition for binary search algorithm?

There must be mechanism to delete and/or insert elements in list

What happens to non delimiter characters?

They are not inserted onto the stack; they are ignored.

The operation of processing each element in the list is known as

Traversal

To represent hierarchical relationship between elements, which data structure is suitable

Tree

Which of the following data structure is non linear data structure?

Trees

Which of the following is two way list?

doubly linked list

Unlike a stack, the items in a queue don't always:

extend all the way down to index 0.

Linked lists are best suited

for the size of the structure and the data in the structure are constantly changing

When converting binary tree into extended binary tree, all the original nodes in binary tree are

internal nodes on extended tree

The pop() member function determines if the stack is empty by calling the _____ member function

isEmpty()

Which of the following data structures are indexed structures?

linear arrays

Two dimensional arrays are also called

matrix arrays


Conjuntos de estudio relacionados

Challenges in the Late 1800s Questions

View Set

Vocabulary From Latin and Greek Roots — Book VI, Unit 3 (Sentences)

View Set

Medical Terminology True or False

View Set

Modules 11 - 13: IP Addressing Exam

View Set

Scientific Inquiry Ray- Chapter 1 Midterm

View Set

SAS Statistics, SAS Visual Analytics, SAS DataFlux

View Set

Medical Assisting Profession Questions

View Set