CSD201

Ace your homework & exams now with Quizwiz!

0

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

B

9) If every node u in G is adjacent to every other node v in G,A graph is said to be ........ A. isolated B. complete C. finite D. strongly connected.

Extended binary tree

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

Deque

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

simple graph

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

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.

P contains the address of an element in DATA.

A variable P is called pointer if

Recursion

An algorithm that calls itself directly or indirectly is known as

sorted binary trees

Binary search algorithm cannot be applied to

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

Consider the AVL tree below. What is the breadth first traversal of the tree after inserting a node with value 24?

The tree is full but not complete.

Consider the binary tree below. Which statement is correct?

The tree is neither complete nor full.

Consider the binary tree below. Which statement is correct? (full binary tree = proper binary tree = 2-tree)

C

Consider the following function: 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? A. fun(1012); B. fun(I00); C. fun(-1012); D. fun(0);

n>=0 && n<15

Consider the following function: voidfun(int n) {if (n < 0) {System, outprintlnf-"); fun(-n); } else if(n<15) System.outprintln(n): else {fun(n/15); System.outprintln(n%15): } } What values of n are directly handled by the stopping (base) case? A. n<0 B. n <15 C. n >= 15 D. n>=0&& n<15

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

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 and pivot = a[0] for quicksort

elementary items & atoms & scalars

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

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.

4F403F205F20

Given a raw message 'FFFF0000FFF00FFFFF00' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

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:

01

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)

E

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: declare an empty array H (which will contain Hamilton cycle) (1) Put the vertex X to H (2) Check if H is a Hamilton cycle then 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 a bad selection (so you do not select it in the same way again). Go to (2). Suppose a G is given below (view picture). Which of the followings is the Hamilton cycle from the vertex A. created by above algorithm? A. A.C. D. E.B.A B. A.D.E.C.B.A C. A.B.C. D. E. A D. A.B.C. D. E.C.A E. A.B.C. E. D. A

0

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

Input-restricted deque

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

top1=top2 && top1=top2-1

If the two stacks are implemented on a single array, the overflow occurs at

thread

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

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 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

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

for relatively permanent collections of data.

Linked lists are best suited

may use a queue

Multi-programming.

it deletes the node p.

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

True

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

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 0(n). and the worst case is 0(n~2)

Select the most correct statement about the complexity of insertion sort

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

Select the most correct statement about the complexity of selection sort

A

Specify the correct implementation of in-order traverse algorithm for binary trees. A. void inOrder(Node p) {if (p != null) {inOrder(p.left): visit(p); inOrder(p.right):} B. void inOrder(Node p) { inOrder(p.left): visit(p); inOrder(p.right):} C. void inOrder(Node p) {if (p != null) {visit(p): inOrder(p.left); inOrder(p.right):} } D. void inOrder(Node p) {if (p == null) {inOrder(p.left): visit(p); inOrder(p.right):}

In chaining ... keys or references to keys.

Specify the correct statement about chaining method for handling collision

Saving data storage

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

4

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

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)

A

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) What does the list look like after the following java code snippet is run? intx = 13: Node f= head: while(f.next != p) f = f.next Node q = new Node(x); q.next= p: f.next = q: A. 7 11 6 4 3 13 9 8 21 B. 13 7 11 6 4 3 9 8 21 C. 7 13 11 6 4 3 9 8 21 D. 7 11 6 4 3 9 8 21 13 E. 7 11 6 4 3 9 13 8 21

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)

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)7

FIFO

The Order followed by stack data structure is

O(log n)

The complexity of Binary search algorithm is

O(n2)

The complexity of Bubble sort algorithm is

0(nlog n)

The complexity of heap sort is

O(n)

The complexity of linear search algorithm is

O(n log n)

The complexity of merge sort algorithm is

Dn = log2n + 1

The depth of a complete binary tree is given by

E

The following is an algorithm for finding Euler cycle from the vertex X using stack: * Answer declare a stack S of characters (a vertex is labeled by a character) declare an empty array E (which will contain Euler cycle) push the vertex X to S while(S is not empty) {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 vertex Y (by alphabet order), which is adjacent to ch.push Y to S and remove the edge (ch.Y) from the graph } The last array E obtained is an Euler cycle of the graph Suppose a multigraph G is given below (view picture). Which of the following is the Euler cycle from the vertex B. created by above algorithm? A. B.A.B.D.C.B B. B.C.D.A.B C. B.C.D.B.A.B D. B.A.C.D.B E. B.D.C.B.A.B E. A.B.C. E. D. A

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

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

base address

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

pop

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

Traversal

The operation of processing each element in the list is known as

ABDECF

The post order traversal of a binary tree is DEBFC. Find out the pre order traversal

underflow

The situation when in a linked list START=NULL is

stacks

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

Tree

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

tables arrays && matrix arrays

Two dimensional arrays are also called

AABBBCAB

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

30 5 40 10 35 25 20

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

5 1 7 4 6 8 3

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

2.1.4. 3. 7. 6. 8

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

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

What is the correct definition of a hash table?

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 4 8 1 6 9 3

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

94

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

87

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

oGdorig

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

riSgMdo

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

ToDay

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

n==0&& n<35

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

internal nodes on extended tree

When converting binary tree into extended binary tree, all the original nodes in binary tree are

overflow

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

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,

fun(-1012);

Which call will result in the most recursive calls?

Queues

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

B

Which of the following applications may use a queue? A. Undo sequence in a text editor. B. Multi-programming. C. Keeping track of local variables at run time. D. Store all variables in a program.

Auxiliary data structure for algorithms.

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 stack?

Arrays

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

Records

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

linear arrays

Which of the following data structures are indexed structures?

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

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

There must be mechanism to delete and/or insert elements in list

Which of the following is not the required condition for binary search algorithm?

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

Which of the following is two way list?

FIFO lists

Which of the following name does not relate to stacks?

Quick sort

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

12

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)?

False

pointers store the next data element of a list

True

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

pre-order traverse algorithm

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

True

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

fun(-1025)

which call will result in the most recursive calls ?

B

{if(n > 0) {System.outprint(" " + n % 5); fun(n): } } What will happen if the statement fun(33); is run? A. The results are nondeterministic B. The operating system detects the infinite recursion because of the "repeated state" C. The program keeps running until you press Ctrl-C D. The run-time stack overflows, halting the program


Related study sets

Module 2 - Unit 1: Digital Content

View Set

NR599 Nursing Informatics: Mid Term_2021

View Set