CSD201

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

ABBCD

10000010011

7 1 6 4 3 8 2

7 1 6 4 3 9 8 2

run time

A Linked list can grow and shrink in size dynamically at

run time

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

top1=top2 && top1=top2-1

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

may use a queue

Store a waiting list of printing jobs.

getSize()

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

getSize()

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

Binary search trees

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

True

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

isEmpty()

The pop() member function determines if the stack is empty by calling the member function

ABDECF

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

ABDECF

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

stacks

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

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

The worst case occur in linear search algorithm when

Zero

Value of the first linked list index is _______

Queues

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

Rotation

Which operation is used in DSW Algorithm:

for relatively permanent collections of data

arrays are the best data structures

sorted linear array

binary tree algorithm cannot be applied to

FIFO , First In First Out

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

LIFO

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

strongly connected

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

singly linked list

in a every element contains some data and a link to the next element, which allow to keep the structure

true

in a singly-linked list there is no effecient 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(n)

True

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

0(nlogn)

the complexity of merge sort is

fun(-1025)

which call will result in the most recursive calls ?

Multi-programming

which following applications may use a queue?

keeping track of local variables at run time

which of following applications may use a queue

undo sequence in a text editor, auxiliary data structure for algorithms

which of following applications may use stack?

dequeue

which of following queue operations cold result in queue underflow

Store a waiting list of printing

which of the following applications may use a queue

7 10 6 4 2 13 8 5 3

7 10 6 4 2 13 8 3

b, c, e

Consider a graph below. Cut-vertices in the graph are

Sequentially

Elements of an array are stored in memory

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

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

back

New nodes are added to the _____ of the queue.

back

New nodes are added to the of the queue.

True

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

quick sort

Partition and exchange sort is

Both of the above

Sorting algorithm can be characterized as

isEmpty()

The pop() member function determines if the stack is empty by calling the _____ member function

Accessing arrays or string elements

The reason for using pointer is ...

delete a

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

oGdorig

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

Undo sequence in a text editor

Which of the following applications may use a stack?

(Strings, Lists, Stacks)= True.

Which of the following data structure is linear type?

All operations are at one end

Which of the following is the feature of stack?

FIFO , First In First Out

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

4

a binary tree with 14 nodes. the minimum possible height of T

Radix sort

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

B, D, C, B, A, B

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

if the coalesced method is used for collision resolution, insertion and searching always take constant time 0(1)

correct statement about hasing algorithm

True

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

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

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

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?

Insertion

is putting an element in the appropriate place in a sorted list yields a larger sorted order list.

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

select the most correct statement

undo sequence in the text editor

which of the following applications may use a stack

dequeue

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

27 11 6 4 3 10 19 8 2

27 11 6 4 3 10 8 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)

7 11 6 14 5 3 9 8 12

7 11 6 14 3 9 8 12

7 11 6 4 3 35 15 8 12

7 11 6 4 3 15 8 12

by replacing each ... new external node

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

Extended binary tree

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

difference bw linear and record

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

True

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

for relatively permanent <benvung> collections of data

Arrays are best data structures

for relatively permanent collections of data

Arrays are best data structures

True

Arrays are dense lists and static data structure

for relatively permanent collections of data

Arrays are the best data structures

O(n)

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

sorted binary trees

Binary search algorithm can not be applied to

sorted linked list

Binary search algorithm can not be applied to

The getFront method would require linear time.

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 first data from the set to be store

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

Last-In-First-Out. A stack is a LIFO storage mechanism because the last item inserted is the first one to be removed.

Explain LIFO

1. Read the characters from a string one at a time.

Explain how you would create an algorithm that matches delimiters on the stack. Include errors in your explanation.

4F4O3F2O5F2O

FFFFOOOOFFFOOFFFFFOO

Search

Finding the location of the element with a given value is

3B4Y3B2Y5B2Y

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

infinity

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?

0

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

(rear + 1) % CAPACITY

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?

Selection

If the number of records to be sorted is small, then...sorting can be efficient.

u is processor and v is successor

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

array

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

True

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

At the head

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

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

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

efficient sorting

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

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

One difference between a queue and a stack is:

True

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

All

Pushdown list means:

Stack , Queue, Linked list

Pushdown list means:

True

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

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 *

Both best and worst cases are O(nlogn)

Select the most correct statement about the complexity of heapsort

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

Select the most correct statement about the complexity of merge sort

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

Select the most correct statement about the complexity of selection sort

4

T is a binary tree with 14 nodes. what is the minimum possiple height of T

when item is somewhere in the middle of the array

The Average case occurs in linear search algorithm

True about Stack

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

O(log n)

The complexity of Binary search algorithm is

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

The complexity of DFS is O(

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

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

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.

ABDECF

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

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

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

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

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

27 11 6 4 3 10 19 8 2

What does the list look like after the following java code snippet is run? intx = 19;

They are not inserted onto the stack; they are ignored.

What happens to non delimiter characters?

...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 4?

84

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

Something between -15 and -100

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

94

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

87

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

Adoretfoo

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

FAEKCDHGB

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

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

Where does the term queue come from?

It depends on the problem

Which graph representation is best?

Auxiliary data structure for algorithms.

Which of the following applications may use a stack?

Keeping track of previous choices(as in backtracking).

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?

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

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

Null case

Which of the following case does not exist in complexity theory

Arrays

Which of the following data structure is linear data structure?

All off string,list,queue

Which of the following data structure is linear type?

Trees

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

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?

doubly linked list

Which of the following is two way list?

LIFO

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

Exchange

is rearranging pairs of elements which are out of order, until no such pairs remain.

Radix sort

is the method used by card sorter.

O(n+logn)

order is the best possible for array sorting algorithm which sorts n item.

saving data strorage

specify the reason for data compression

fun(-1023)

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?

0 4

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?

n>=0 && n<15

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

Hash function h(x) transform a particular key x, etc into an index i=h(x) in the table

what is the correct definition of a hash function?

7

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

87

what is the value of the Boundary Folding Hash Function if K = 43-57-69 and Tsize = 100

88

what is the value of the Boundary Folding Hash Function if K = 45-65-79-8 and Tsize = 100

94

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

84

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

97

what is the value of the Shift Folding Hash Function if K = 45-65-79-8 and Tsize = 100

84

what is the value of the shift folding hash function if K= 43-65-69-7 and Tsize = 100?

All of above

A connected graph T without any cycles is called

pop

A operation for moving and returning the top element of the stact is traditionally called

Link

Each entry in a linked list is called a _______

Sequentially

Elements of an array are stored _______ in memory

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

add

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

| 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

True

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

Recursion

An algorithm that calls itself directly or indirectly is known as

sorted binary trees

Binary search algorithm cannot be applied to

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

a tree graph & free tree & a tree

A connected graph T without any cycles is called

Deque

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

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

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

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;

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

Select the most correct statement about the complexity of selection sort

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?

3

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

FIFO

The Order followed by stack data structure is

O(n2)

The complexity of Bubble sort algorithm is

0(nlog n)

The complexity of heap sort is

Traversal

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

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?

(Strings, Lists, Stacks)= False.

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

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?

In push operation = False.

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

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?

False

pointers store the next data element of a list

for relatively permanent collections of data.

Linked lists are best suited

for the size of the structure and the data in the structure are constantly changing

Linked lists are best suited

it deletes the node after p.

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

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

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

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

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

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

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

Select the most conect statement about the complexify of insertion sort

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

Select the most correct statement:

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

Multi-programming

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

Store a waiting list of printing jobs

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

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

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

In chaining ... keys or references to keys.

Specify the correct statement about chaining method for handling collision

True

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

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)

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?

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

cursor = cursor.link;

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?

obj = s

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.

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

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;"?

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 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 does the java code snippet below do? Node f=head; while(f.next!=p) f=f.next; f.next=p.next;

data[12]

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[10]

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?

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

O(n2)

The complexity of bubble sort algorithm is

O(n)

The complexity of linear search algorithm is

O(n log n)

The complexity of merge sort algorithm is

O(n log n)

The complexity of merge sort algorithm is a.

V|2) ,Sequential Coloring algorithm establishes the sequence of | True about Graph coloring

The complexity of sequential Coloring algorithm is O(

running time

The complexity of sorting algorithm measures the ...... as a function of the number n of items to be sorter.

Dn = log2n + 1

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

The depth of a complete binary tree is given by

All of above

The difference between linear array and a record is

all

The difference between linear array and a record is

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

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

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.

True about tree

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

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

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

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

True about Stack

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

True about Doubly linked list

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

enqueue

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

enqueue

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

push

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

pop

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:

Accessing arrays or string elements

The reason for using pointer is ... Choose the false option from the following sentences

True

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

False about skip list

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

underflow

The situation when in a linked list START=NULL is

a. size of variable name + b. size of (struct tag)

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

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

delete a;

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

One stack is enough.

To evaluate an expression without any embedded function calls:

Tree

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

tree

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

both of above: table,matrix

Two dimensional arrays are also called

tables arrays && matrix arrays

Two dimensional arrays are also called

extend all the way down to index 0.

Unlike a stack, the items in a queue don't always:

ABBCD

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

AABBBCAB

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

Zero

Value of the first linked list index is

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

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

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

What is "peek"?

Removing a data item from the top of the stack.

What is "popping"?

A double-ended queue. You can insert items and either end & delete items from either end.

What is a deque?

Vectors grow automatically as needed.

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

Placing a data item on top of the stack.

What is the "push"?

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?

4 2 7 1 3 6 8

What is the breadth-first traversal of a tree below after deleting the node 5 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?

dai nhat

What is the correct definition of a hash function?

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)

What is the difference between a stack and a queue?

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

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

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

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

What is wrapping around? When is it useful? What is created that must be fixed?

HowAreYouT

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

iserCeliF

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

dorino

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

risgnMog

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

steprac

What is written to the screen for the input "carpets"?

Lists implemented with an array.

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

appendNode()

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

Auxiliary data structure for algorithms.

What of the following applications may use a stack?

n>=0 && n<15

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

Methods.

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

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

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

null case

Which of the following case does not exist in complexity theory

All of above

Which of the following data structure is linear type?

None of above

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

None of string,list,stack

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

Math.random() < P

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

Protected, Private

Which of the following keywords are access modifier:

Traversal through tree Transformation

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

Merge sort

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

Selection sort

Which of the following sorting algorithm is of priority queue sorting type?

pop

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

pointers store the next data element of a list

Which of the following statement is false?

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

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

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

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

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?

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

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

simple graph

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

double linked list

a node contains some data and one link to its successor and one link to its predecessor in the list

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

for relatively permanent collections of data

linked list are best suited

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

push() method of the stack

best case 0(n), worst case 0(n^2)

select the most correct statement about the complexity of bubble sort

Insertion

sorting algorithm is frequently used when n is small where n is total number of elements.

Object pop(){if(isEmpty())return(null);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.

0(n)

the complexity of countting the number of items in a doubly-linked list

enqueue

the operator for adding an entry to a queue is traditionally called

dequeue

the operator for removing and returning the end element of the queue is traditionally called

A, B, C, E, D, A

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

both of them

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.

simple graph

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

both of them

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.

an Integer

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.

difference bw linear and record

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

pointer array\sorted linear array

Binary search algorithm cannot be applied to

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)

fun(-1023);

Consider the following function: 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?

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

. Both push and pop would require linear time.

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.

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?

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?

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

True about singly linked list

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

False

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

the first data from the set to be stored

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

Scalars, atoms, elementary items

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

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

all: elementary ,atom,scalar

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

Link

Each entry in a linked list is called a

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.

Search

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

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

D, C, F, B, G, A, E, 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).

4F4O3F2O5F2O

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

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

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

H, A, B, D, T

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

27

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

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

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

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.

How is a priority queue different than a queue?

front changes., rear changes.

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?

Input-restricted deque

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

strongly connected

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

True

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

DCBA

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?

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.

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

In a Heap tree

Singly linked list

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

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

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

e begin, u is profe

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

e begins at u and ends at v

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

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

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

all of above

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

endpoints,adjacent node,neighbors

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

difference bw linear and record

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

T

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

False

In all cases, nonrecursive implementation is faster recursive implementation

Array

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

False

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

True

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

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

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

None of these operations require linear time.

In the array version of the Stack 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 circular array version of the Queue class, which operations require linear time for their worst-case behavior?

None of these operations require linear time.

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

At the tail

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

False=(getFront, isEmpty, insert )

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

False=(is_empty,peek,pop,push)

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

None of these operations require linear time.

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

pop() method of a stack of Integers.

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

tree graph,free tree,a tree

A connected graph T without any cycles is called

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

3

How many parts are there in a declaration statement?

Input-restricted deque

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

False

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

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? (please note that the tree is still AVL)

Tree

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

matrix arrays

Two dimensional arrays are also called

7

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

Both best and worst cases are (nlogn)

select the most correct statement about the complexity of heapsort

both best and worst 0(nlogn)

select the most correct statement about the complexity of heapsort

best case O(n), worst case 0(n^2)

select the most correct statement about the complexity of insertion sort

both best and worst 0(n^2)

select the most correct statement about the complexity of selection sort

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

singly linked list

in chaining, only some possition of the table is associated with a linked list of chain of structrures whose info fields strore keys or references to keys

specify the correct statement about chaining method for handling collision

some possition of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys

specify thof the e correct statement about chaining method for handling collision

4

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

All of the above

ushdown list means:

True

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

*(/n)***(/n)*****(/n)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?

1 3 5 7 9

void fun(int n) {if(n > 0) { fun(n-2); System.out.print(" " +n ); } } What is the output when the statement fun(9); is run?

The operating system detects the infinite recursion because of the "repeated state"

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

True

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

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

is a array in memory used ... into an index i=h(x) in the table

what is the correct definition of a hash table?

94

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

doubly linked list

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

by replacing each empty sub tree by a new external node

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

an Integer

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

P contains the address of an element in DATA

A variable P is called pointer if

sorted singly linked list

Binary search algorithm can not be applied to

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)

100

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% 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)

101

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% Using Huffman encoding, what is the code for character E?(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)

4

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

3

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?

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.

How does the mail sorting analogy apply to the priority 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.

How is "peek" different in a queue?

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

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?

Only rear changes

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?

complete

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

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?

True

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

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

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?

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:

complete

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

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

endpoints of e & adjacent nodes & neighbors

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

riSgMdo

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

Quick sort

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


संबंधित स्टडी सेट्स

Sports Psych ch.14 Self Efficacy

View Set

ch. 18 lesson 3 world history- napoleon

View Set

prep u chap 25: management of pts with complications of heart disease

View Set

Chapter 2 Section 1 Introduction To Food Safety

View Set