You are on page 1of 21

1) In a doubly-linked list, each node contains a link to the

- Previous node only

- Next node only

- first node and the next node

- Previous as well as the next node

2) Which of the following properties of algorithms states that each step in an algorithm is unambiguous.

- Effectiveness

- Definiteness
- Efficiency

- Finiteness

3) Joe is assigned a task to develop a code to implement a delete operation on a stack implemented in
the form of a linked list. Identify the correct algorithm that would enable him to accomplish this task.

- 1 . Make a variable/pointer tmp point to the last node.


2.Retrieve the value contained in the topmost node.
3.Make top point to the next node in sequence.
4.Release memory allocated to the node marked by tmp.
- 1 . Make a variable/pointer tmp point to the topmost node.
2.Retrieve the value contained in the topmost node.
3.Release memory allocated to the node marked by tmp.
- 1 . Make a variable/pointer tmp point to the topmost node.
2.Retrieve the value contained in the topmost node.
3.Make top point to the next node in sequence.
4. Release memory allocated to the node marked by tmp.
- 1 . Make a variable/pointer tmp point to the topmost node.
2.Retrieve the value contained in the topmost node.
3.Make top point to the first node.
4.Release memory allocated to the node marked by tmp.

4) Which of the following is a condition for queue overflow?

- FRONT = 0 and REAR = last index position


- FRONT = REAR

- FRONT = 0 and REAR = first index position


- FRONT = 1 and REAR = last index position

5) Printer spooling is an application of which of the following data structures?

- Queues

- Linked List
- Trees
- Stacks
6) Jim is assigned a task to develop a code to display all the elements in a circular linked list. Identify the
correct algorithm that would enable him to accomplish this task.

- 1 . Make currentNode point to the successor of the node marked as LAST, such that currentNode
points to the first node in the list.
2.Repeat step 3 and 4 until currentNode = LAST.
3.Display the information contained in the node marked as currentNode.
4.Make currentNode point to the next node in its sequence.
5.Display the information contained in the next field of node marked as LAST.
- 1 . Make currentNode point to the successor of the node marked as LAST, such that currentNode
points to the first node in the list.
2.Repeat step 3 and 4 until the next field of currentNode = LAST.
3.Display the information contained in the node marked as currentNode.
4.Make currentNode point to the next node in its sequence.
5.Display the information contained in the node marked as LAST.

- 1 . Make currentNode point to the successor of the node marked as LAST, such that currentNode
points to the first node in the list.
2.Repeat step 3 and 4 until currentNode = LAST.
3.Display the information contained in the node marked as currentNode.
4.Make currentNode point to the next node in its sequence.
5.Display the information contained in the node marked as LAST.

- 1 . Make currentNode point to the successor of the node marked as LAST, such that currentNode
points to the first node in the list.
2.Repeat step 3 until currentNode = LAST.
3.Display the information contained in the node marked as currentNode.
4.Display the information contained in the node marked as LAST.
5.Make currentNode point to the next node in its sequence.

7) Henry has written a code to sort a given list of items using insertion sort. When the code is executed,
the user enters a list of 10 elements in the reverse order. How many comparisons will be made in the
first pass?

- 10
- 1
- 11
- zero
8) Jim has written the following algorithm to insert a node at the end of a singly-linked list.
1.Allocate memory for the new node.
2.Assign value to the data field of the new node.
3.If START is NULL, then:
a. Make START point to the new node.
b. Make LAST point to the new node.
c. Go to step 6.
4.Mark the new node as LAST.
5.Make the next field of LAST point to the new node.
6.Make the next field of the new node point to NULL.

However, the given algorithm does not give the desired output. Identify the reason and provide the
correct solution.

- The sequence of steps 4 and 5 is incorrect.

- In step 5, the next field of LAST should be made to point to NULL.


- The sequence of steps 3 and 6 is incorrect.

- In step 6, the next field of new node should be made to point to LAST.

9) Consider the given algorithm.


1.Initialize the stack to be empty.
2.Scan the entries in the infix expression from left to right until the end of the infix expression is
encountered:
a. If an operand is encountered, PUSH it into the stack.
b. If an operator is encountered:
I . POP the top two values.
I. Operate the two values by using the operator. I N . PUSH the result to the stack.
3. Get result from the top of the stack.
Which of the following statements is true about the given algorithm?

- The given algorithm will give an error.


- The given algorithm will evaluate the postfix expression.
- The given algorithm will convert an infix expression to a postfix expression.

- The given algorithm will evaluate the infix expression. Consider the following statements:

10) Statement A: Representation of a circular linked list is similar to a singly-linked list.


Statement B: Doubly-linked list has only one pointer that points to the next node.

Which one of the following options is correct with respect to the above statements?

- Both, Statement A and Statement B, are True

- Statement A is True and Statement B is False

- Both, Statement A and Statement B, are False

- Statement A is False and Statement B is True


11) Which of the following is defined as a graph with no cycles?

- Spanning Subgraph

- Complete Graph

- Acyclic Graph

- Connected Graph

12) Consider the following algorithm:


1.Accept the element
2.Set lowerbound = 0
3.Set upperbound = n - 1
4.Set mid = (lowerbound + upperbound)/2
5.If arr[rnid] = desired element:
a. Display "Found"
b. Go to step 10
6.If desired element < arr[mid]:
a. Set upperbound = mid - 1
7.If desired element > arr[mid]
a. Set lowerbound = mid + 1
8.If lowerbound <= upperbound: a.
Go to step 4
9.Display "Not Found"
10. Exit

Identify the output of the given algorithm.

- The given algorithm will search an element in a list by


using an index

- The given algorithm will search an element in a list by


using the hashing technique

- The given algorithm will search an element in a list by


using the binary search technique

- The given algorithm will search an element in a list by


using the linear search technique

13) Consider the following statements:

Statement A: In separate chaining, you use links/pointers to resolve


hash clashes.
Statement B: In separate chaining, each slot in the hash table contains
the address of the first node of a distinct linked list.

Which one of the following options is correct with respect to the above
statements?

- Statement A is True and Statement E is False

- Both, Statement A and Statement E, are False

- Both, Statement A and Statement E, are True

- Statement A is False and Statement E is True


14) In which of the following hashing techniques you square the key,
and then take some digits from the middle of the number as an
address of the corresponding key?

- Truncation Method

- Modular Method

- Mid Square Method

- Folding Method

15) Kim is working with Royal Inc. as a data analyst. She has been
provided with a list of products, the company deals with. She is
required to sort the list.
The sorting algorithm adopted by her is as follows:

1.Repeat steps 2 and 3 varying j from 0 to n - 2


2.Find the index of the minimum value in arr[j] to arr[n - 1 ]
a. Set rninjndex = j
b. Repeat step c varying i from j + 1 to n - 1
c. If arr[i] < arr[min_index]:
I . rninjndex - I
3. Swap arr[j] with arr[min_index]
Which sorting technique is Kim using?

- Merge Sort

- Bubble Sort

- Quick Sort

- Selection Sort

16) How many comparisons are required to sort an array of 1 2


elements by using bubble sort?

- 12

- 78

-11

- 66

17) Consider the following statements:

Statement A: A recursive function is a function that invokes itself.


Statement B: Recursion helps in writing clear, short, and simple
programs.

Which one of the following option is correct with respect to the above
statements?

- Statement A is False and Statement B is True

- Statement A is True and Statement B is False

- Both, Statement A and Statement B, are False

- Both, Statement A and Statement B, are True


18) Consider the following statements.
Statement A: Algorithms based on greedy approach are used for
solving optimization problems, where you need to maximize profits or
minimize costs under a given set of conditions.
Statement E: The greedy approach is an algorithm design technique
that involves breaking down the problem recursively into sub problems
until the sub problems become so small that they can be directly
solved

- Both statement A and statement E are false

- Both statement A and statement E are true

- Statement A is false and statement E is true

- Statement A is true and statement E is false

19) The given algorithm deletes a node between the two nodes in a
singly-linked list.

1. Locate the node to be deleted. Mark the node to be deleted as


current and its predecessor as previous. To locate current and
previous, execute the following steps:
a. Set previous = START.
b. Set current = START.
c. Repeat steps d and e until either the node is found
or
current becomes NULL.
d. Make current point to previous.
e. Make previous point to the next node in sequence.
2.Make the next field of previous point to the successor of current.
3.Release the memory for the node marked as current.

However, the preceding algorithm is not giving the results, as


required. Identify the error in the algorithm.
- Step 3 should come before step 2.

- Step d should be replaced by: Make previous point to current,


and step e should be replaced by: Make current point to the next
node in sequence.

- Step e should be replaced by: Make current point to the next node
in sequence.

- Step d should be replaced by : Make previous point to current.


20) The following is a file containing the details about the stationary
available at the Books On-Dernand Stores. It contains data about the
item, itemid, iterntype and iterncode.

<STATION ARYDETAILS ITEMCODE=C089>


<STATIONARY>
<ITEMTYPE>"Pen"<ITEMTYPE>
<ITEMCOLOR>"Blued"</ITEMCOLOR>
</STATIONARYDETAIL>

The data structure matches the schema but there are errors in the
code. Identify the errors.

1 . The STATIONARYDETAILS, ITEMID and ITEMTYPE tags are not


closed properly.
2.The data between the tags should not be enclosed in double
quotes.
3.The STATIONARY tag should have a closing tag.

1 . The STATIONARYDETAILS and ITEMTYPE tags are not closed


properly.
2.The attribute data should be enclosed in quotes.
3.The STATIONARY tag should have a closing tag.
1 . The STATION ARYDETAILS and ITEMCOLOR tags are not closed
properly.
2.The data between the tags should not be enclosed in hyphens.
3.The DRESS tag should have a closing tag.
1 . The STATION ARYDETAILS and ITEMID tags are not closed properly.
2.The data between the tags should be enclosed in exclamation
marks.
3.The STATIONARY taq should have a closinq taq.

21) Which of the following sorting techniques will you use, if the list to
be sorted is small in size and is nearly sorted?

- Insertion Sort

- Bubble Sort

- Selection Sort

- Quick Sort

Identify the code for displaying a Web document at two locations


ahead of the active Web document.

22) <HTML>
<head>
<title>Link the Docurnents</title>
<body>
<A href ="javascript: hi story(2)j">
<IMG BORDER = 0 src= "arrow.gif>
</A>
</body>
</head>
</HTML>
<HTML>
<head>
<title>Link the Docurnents</title>
<body>
<A href ="javascript:history.next(2)/> <IMG
BORDER = 0 src= "arrow.gif > </A> </body>
</head> </HTML> 3 <HTML> <head>
<title>Link the Docurnents</title>
<body>
<A href ="history.go(2);"> <IMG BORDER = 0
src = "arrow.gif > </A> </body> </head>
</HTML> 3 <HTML> <head>
<title>Link the Docurnents</title>
<body>
<A href =ijavascript:historY.go(2);">
<IMG BORDER = 0 src= "arrow.gif >
</A>
</body>
</head>
</HTML>

Identify the correct tags for inserting JavaScript code in an HTML code.

- <SCRIPT ="JavaScript">
</SCRIPT>

- <SCRIPT>
< LAN G U AG E="J avaS c h
pt" > </SCRIPT>

- <JavaScript SCRIPT>
</SCRIPT>
- <SCRIPT LANGUAGE="JavaScript">
</SCRIPT>

Which of the following statements are NOT true about the


DOMDocument object?
l)You can use the DOMDocument object to load an XML document,
parse it, and validate it.

ll)You can use the properties of the DOMDocument object to format


data.

lll)You can use the DOMDocument object to load the schema document
associated with the XML document.

3 1,11
and III 3 II
and III I

and III

I and II

The following code snippet is written to create a new node called


STUDENTGROUP.
varmyxmldoc = new ActiveXObject("Msxml2.DOMDocument.6.0"); If
(myxmldoc.childNodes.length==l)
{
rnyroot=rnyxrnldoc.createNode("StudentGroup");
myxmldoc.appendChild(myroot);
myxrnldoc.saveCd^codedoc.xrnr);
}

However, the implementation of the code fails to create a new node.


Identify the error and suggest correction.

The code has the following errors:


1.The value for testing the length of the child note is incorrect. The
test condition should check the length to be less than 0.
2.The parameters passed in the createNode function are incorrect.
The correct function implementation is createNode(0,"
StudentGroup
II

i
n

J
)
The code has the following errors:
1.The value for testing the length of the child note is incorrect. The
test condition should check the length to be greater than 0.
2.The parameters passed in the createNode function are incorrect.
The correct function implementation is createNode(l," StudentGroup
")

The code has the following errors:


1.The value for testing the length of the child note is incorrect. The
test condition should check the length to be greater than 1.
2.The parameters passed in the createNode function are incorrect.
The correct function implementation is createNode("","
StudentGroup "," ")
The code has the following errors:
1.The value for testing the length of the child note is incorrect. The
test condition should check the length to be equal to 0.
2.The parameters passed in the createNode function are incorrect.
The correct function implementation is createNode(l," StudentGroup
V ")
The data about books is stored in an XML document. This data needs
to be formatted. The data about books priced higher than $100 and all
the books priced $75 need to be displayed in RED. Which of the
following conditional constructs should you use to specify the above
criteria?

3 <xsl:if test="PRICE[. > 1 00 and . = 75]">


" <xsl:if test="PRICE[. > 100 or . = 75]">

3 <xsl:if test=PRICE[. > 100] or PRICE[. = 75]>


3 <xsl:if test="PRICE[. > 100] and PRICE[. = 75]">

Consider the following statements:

Statement A: Style sheet is used to transform an XML document into


resultant tree structure, which is then used to render the XML
document to a specific target.
Statement E: Style sheet describes how to present the transformed
Information.

Which of the following options is correct with respect to the preceding


statements?

Both Statement A and Statement E are

false. 3 Statement A is false and Statement


B is true.

Both Statement A and Statement B are

True. 3 Statement A is true and statement B


is false.

Which of the following tasks CANNOT be performed through a style


sheet?

Sorting content 3
Implementing filters 3 Creating
labels and headings 3 Specifying
attributes for entities

Consider the following algorithm to convert an infix expression to a


postfix expression:
1.Initialize the stack to be empty.
2.Initialize the postfix string to be empty.
3.Scan the entries in the infix expression from left to right until the
end of the infix expression is encountered:
a. If the scanned entry is:
i. An operand: Append the operand to the postfix
string.
ii. An operator: Compare the precedence of the operator
with the operator on the top of the stack. If the precedence of the
operator on the top of the stack is greater than or equal to the
precedence of the scanned operator, pop the operator from the stack
and append it to the postfix string. Repeat this step until the
operator at the top of the stack has a precedence less than the
scanned operator or the stack becomes empty. Finally, push the
scanned operator onto the stack.
iii. A left parenthesis: Push the left parenthesis onto the stack.
iv. A right parenthesis: Pop stack elements one by one and
append them to the postfix string until a left parenthesis is popped.
4. Pop all entries from the stack and append them to the postfix
expression.

Identify the error in the algorithm, if any.

3 The given algorithm will not give the desired output because step
3(a)(ii) is incorrect.

3 The given algorithm will give the desired output.

3 The given algorithm will not give the desired output because step
3(a)(iii) is incorrect.

3 The given algorithm will not give the desired output because step
3(a)(i) is incorrect.

Which of the following symbol is used to display the less than (<)
symbol?

3 It;
3
alt;
-ait
-it

Ed Young decided to create a personal Web site. Identify the interface


design rules that Ed needs to follow.

3 Use the underline attribute of HTML for emphasizing text.


Use images for bullets. 3 Use the uniform
interface across the Web site. 3 Use graphic
elements as buttons.

Consider the following extract from an XML document, which contains


the details about a product and the order details for the product:
<PRODUCT PRODID="P001" NAME="CD">
<PRICE> $10 </PRICE>
</PRODUCT>
<ORDER ORDNO="l 00">
<QTY> 200 </QTY>
</ORDER>
When the above document is opened in IE 5.0, it gives an error
message. What could be the cause of the error?

The value of the ORDNO attribute is numeric and, therefore, should


not be enclosed in quotes.

3 The XML document contains more than one root element.


3 The tags are not nested correctly.
The XML document does not contain the processing instruction.
Which of the following statements correctly states the difference
between HTML and XML?

3 HTML focuses on presentation of data, while XML focuses only on


data and not on its presentation.

3 HTML focuses on data, while XML focuses on the presentation of


data.

3 HTML focuses only on the presentation of data, while XML focuses


on data as well as its presentation.

3 HTML focuses on data as well as its presentation, while XML focuses


only on data.

Which of the following is NOT a markup language? 3


XML
2SGML
3HTML 3
Java

Which of the following is the most appropriate algorithm to insert an


element in a binary tree?

3 1. Allocate memory for the new node


2.Assign value to the data field of the new node.
3.Make the left and right child fields of the new node point to
NULL.
. 4. Locate the position of the parent of the node to be inserted.
Mark it as parent.
5. If parent is NULL
a. Make the new node as the root node
b. Exit
6. If value of the new node is less than that of the parent
a. Make left child field of parent point to the new node
b. Exit.
7. If value of the new node is greater than that of the parent
a. Make right child field of parent point to the new node
b. Exit.
3 1 . Allocate memory for the new node
2.Assign value to the data field of the new node.
3.Make the left and right child fields of the new node point to
NULL.
4.Locate the position of the parent of the node to be inserted.
Mark it as parent.
5.If value of the new node is less than that of the parent
a. Make left child field of parent point to the new node
b. Exit.
6. If value of the new node is greater than that of the parent
a. Make right child field of parent point to the new node
b. Exit.
3 1 . Allocate memory for the new node
2.Assign value to the data field of the new node.
3.Make the left and right child fields of the new node point to
NULL.
4.Locate the position of the parent of the node to be inserted.
Mark it as parent.
5.If parent is NULL
a. Make the new node as the root node
b. Exit
6. If value of the new node is less than that of the parent
a. Make right child field of parent point to the new node
b. Exit.
7. If value of the new node is greater than that of the parent
a. Make left child field of parent point to the new node
b. Exit.
3 1 . Allocate memory for the new node
2.Assign value to the data field of the new node.
3.Make the left and right child fields of the new node point to
NULL.
4.Locate the position of the parent of the node to be inserted.
Mark it as parent.
5.If value of the new node is less than that of the parent
a. Make right child field of parent point to the new node
b. Exit.
6. If value of the new node is greater than that of the parent
a. Make left child field of parent point to the new node
b. Exit.

Identify the level of node v5 in the given tree.


Click the Exhibit button to view the tree.
3

1
3 4
3 3
The following is the algorihtm to search for a particular value in a
binary search tree:
1.Make currentNode point to NULL
2.If currentNode is not NULL:
a. Display "Not found"
b. Exit
3. Compare the value to be searched with the value of currentNode.
Depending on the result of the comparison, there can be three
possibilities:
a. If the value is equal to the value of currentNode:
i. Display "Found"
ii. Exit
b. If the value is less than the value of currentNode:
i. Make currentNode point to its left child
ii. Go to step 2
c. If the value is greater than the value of currentNode:
i. Make currentNode point to its right child
ii. Go to step 2
However, the given algorithm does not give the desired output.
Identify the error?

3 Step 1 is incorrect. Step 1 should be: Make currentNode point to


the root node

3 Step 3(a) should come after step 3(c )

3 Step 2 should come after step 3

3 Step 1 is incorrect. Step 1 should be: Make currentNode point to


the root node. Step 2 should be: If currentNode is NULL

John has to develop a code to locate the inorder successor of a node in


a threaded binary tree. Identify the correct algorithm that would
enable him to accomplish this task.

3 1 . Identify the node for which you need to locate the inorder
successor, and mark it as currentNode.
2. Ifthe right child of currentNode is athread:
a. Mark the right child of currentNode as successor.
b. Exit.
3.Make currentNode point to its left child.
4.Repeat step 5 until the left child of currentNode becomes a
thread.
5.Make currentNode point to its left child.
6.Mark currentNode as successor.
3 1 . Identify the node for which you need to locate the inorder
successor, and mark it as currentNode.
2. Ifthe right child of currentNode is athread:
a. Mark the right child of currentNode as successor.
b. Exit.
3.Make currentNode point to its right child.
4.Repeat step 5 until the left child of currentNode becomes a
thread.
5. Make currentNode point to its right child.
5. Mark currentNode as successor.
3 1 . Identify the node for which you need to locate the inorder
successor, and mark it as currentNode.
2. Ifthe right child of currentNode is athread:
a. Mark the right child of currentNode as successor.
b. Exit.
3.Make currentNode point to its right child.
4.Repeat step 5 until the left child of currentNode becomes a
thread.
5.Make currentNode point to its left child.
6.Mark currentNode as successor.
3 1 . Identify the node for which you need to locate the inorder
successor, and mark it as currentNode.
2. Ifthe left child of currentNode is athread:
a. Mark the left child of currentNode as successor.
b. Exit.
3.Make currentNode point to its right child.
4.Repeat step 5 until the left child of currentNode becomes a
thread.
5.Make currentNode point to its left child.
6.Mark currentNode as successor.

Identify the degree of a node, vl, in the given


tree. Click the Exhibit button to view the tree.
- 6
- 4
- 0
3 2
Which of the following code snippets can be considered well-forrned?

3 <EMPLOYEEempid="eOr>
<EMPNAME> James Peterson<BASICPAY> $2000
</EASICPAYx/EMPNAME> </EMPLOYEE>

3 <EMPLOYEEempid="e01">
<EMPNAME> James Peterson<EASICPAY> $2000 </EMPNAME>
</EASICPAY>
</EMPLOYEE>

3 <EMPLOYEE empid=e01 >


<EMPNAME> James
Peterson</EMPNAME>
<BASICPAY> $2000
</EASICPAY> </EMPLOYEE>

3 <EMPLOYEE empid="e01 ">


<EMPNAME> James Peterson<EASICPAY> $2000
</BASICPAYx/EMPNAME> </employee>

What is the address stored in the last node of a


circular linked list?

3 Address of the

current node 3
Address of the first

node " NULL

3 Address of the previous node

If an algorithm is of the order of O(log n), then the


algorithm has a
_________order of growth.

3 Constant

og

Li

ne

ar

3
Ex

po

ne

nt

ial

5
Lo

ga

rit

ic

Harry is assigned a task to develop a code to implement insert


operation in a queue implemented in the form of a linked list.
Identify the correct algorithm that would enable him to accomplish
this task.

3 1. Allocate memory for the new node.


2.Assign value to the data field of the new node.
3.Make the next field of the new node point to NULL.
4.Ifthe queue is empty, execute the following steps:
a. Make FRONT point to the new node
b. Make REAR point to the new node
c. Exit
5. Make the next field of REAR point to the new node.

3 1. Allocate memory for the new node.


2.Assign value to the data field of the new node.
3.Make the next field of the new node point to NULL.
4.Make the next field of REAR point to the new node.
5.Make REAR point to the new node.
3 1 . Allocate memory for the new node.
2.Assign value to the data field of the new node.
3.Make the next field of the new node point to NULL.
4.Ifthe queue is empty, execute the following steps:
a. Make FRONT point to the new node
b. Make REAR point to the new node
c. Exit
5.Make the next field of REAR point to the new node.
6.Make REAR point to the new node.
3 1 . Allocate memory for the new node.
2.Assign value to the data field of the new node.
3.Make the next field of the new node point to NULL.
4.Ifthe queue is empty, execute the following steps:
a. Make FRONT point to the new node
b. Make REAR point to the new node
c. Exit

5. Make REAR point to the new

node.

Consider the given situation.


You have given some print requests to a printer. To store these print
requests, the printer needs a storage mechanism that allows the
requests to be processed on a FCFS basis. Which of the following
data structures will you select for this purpose?

" Stack 3
Trees

Queue 3
Linked List

In which of the following data structures data cannot be deleted from


the middle without first removing all items from the top?

Arrays

3 Trees

3
Queues "

Stacks

Consider the following algorithm:


1.Mark the node to be deleted as current, and its predecessor as
previous.
2.Make the next field of previous point to the successor of current.
3.Ifthe successor of current exists:
a. Make the prev field of the successor of current point to
previous.

4. Release the memory of the node marked as current.

What does the preceding algorithm do?


3 The given algorithm will delete a node only from the end of a
doubly-linked list.

3 The given algorithm will delete a node from the end of a circular
linked list.

3 The given algorithm will delete a node between the two nodes of
a doubly-linked list or a node at the end of a doubly-linked list.

The given algorithm will delete a node from the beginning of a


circular-linked list.

You have to sort a list of 20 elements stored in an array by using


selection sort algorithm.
How many comparisons are performed in the second pass of the
selection sort algorithm?

3 10
3 17
3 18
3 19

Sam has developed a code to delete a node between the two nodes
from a singly-linked list according to the following algorithm:
1. Locate the node to be deleted. Mark the node to be deleted as
current and its predecessor as previous. To locate current and
previous, execute the following steps:
a. Set previous = START.
b. Set current = START.
c. Repeat steps d until either the node is found or current
becomes NULL.
d. Make previous point to current.
e. Make current point to the next node in sequence.
2.Make the next field of previous point to the successor of current.
3.Release the memory for the node marked as current.

However, whenever he deletes the node and selects the display


option to display the contents of the linked list, he does not get the
desired output. Why?

Step 2 is incorrect. In this step, current should be made to point


to the next node in its sequence.

3 Step 1 (c) is incorrect. In this step, both step d and e should be


repeated.

3 Step 1 (b) is incorrect. In this step, current should be made to


point to NULL.

3 Step 2 is incorrect. In this step, the next field of previous should


be made to point to NULL.
Consider the given algorithm.
1.Initialize the stack to be empty.
2.Scan the entries in the infix expression from left to right until the
end of the infix expression is encountered:
a. If an operand is encountered, PUSH it into the stack.
b. If an operator is encountered:
I . POP the top two values.
I. Operate the two values by using the operator.
I N . PUSH the result to the stack.
3. Get result from the top of the stack.
Which of the following statements is true about the given algorithm?

3 The given algorithm will evaluate the postfix expression.


3 The given algorithm will evaluate the infix expression.

The given algorithm will give an error.

3 The given algorithm will convert an infix expression to a postfix


expression.

Next is a pointer that points to the next node of a singly-linked list.


Which of the following values is stored in the Next pointer of the last
node?

Address of its first node "

NULL

Address of the last node

Zero

Which of the following is defined as a graph with no cycles?

3 Acyclic Graph

3 Spanning Subgraph

Connected Graph

3 Complete Graph

Jim is assigned a task to develeop a code to sort a list of elements by


using bubble sort. Identify the correct algorithm that would enable
him to accomplish this task.

3 1. Set pass = 1.
2.Repeat step 3 varying j from 0 to n - 1 - pass.
3.Ifthe element at index j is greater than the element at index j
+ 1,
swap the two elements.
4.Increment pass by 1.
5.If pass <= n - 1 go to step 2.
3 1. Set pass = 1.
2.Repeat step 3 varying j from 0 to n - 1.
3.Ifthe element at index j is greater than the element at Index j
+ 1, swap the two elements.
4.Increment pass by 1.
5.If pass <= n - 1 go to step 2.
J 1. Set pass = 1.
2.Repeat step 3 varying j from 0 to n - 1 - pass.
3.If the element at index j is greater than the element at index
j + 1,
swap the two elements.
4.Increment pass by 1.
5.If pass <= n go to step 2.
3 1. Set pass = 0.
2.Repeat step 3 varying j from 0 to n - 1 - pass.
3.If the element at index j is greater than the element at index
j + 1, swap the two elements.
4.Increment pass by 1.
5.If pass <= n - 1 go to step 2.

You have to search for an element in an array of size 25 by using


linear search algorithm. How many comparisons do you need to
make in
an average case?

3 1
3

Using which of the following techniques, you calculate the offset


address by breaking the keys into parts and then adding them.

3 Modular

Method 3
Folding Method 3
Truncation

Method 3 Mid

Square Method

Kim is working with Royal Inc. as a data analyst. She has been
provided with a list of products, the company deals with. She is
required to sort the list.
The sorting algorithm adopted by her is as follows:

1.Repeat steps 2 and 3 varying j from 0 to n - 2


2.Find the index of the minimum value in arrij] to arr[n - 1 ]
a. Set rninjndex = j
b. Repeat step c varying i from j + 1 to n - 1
c. If arrp] < arr[min_index]:
I . rninjndex = I
3. Swap arrij] with arr[min_index]
Which sorting technique is Kim
using?

Merge Sort

Selection

Sort " Quick

Sort 3
Bubble Sort
How many comparisons are required to sort an array of 8 elements
by using insertion sort, when the list is already sorted?

3
28

3
8 3
64 -

Which of the following sorting techniques sorts the list efficiently,


ifthe list to be sorted is nearly sorted?

Merge Sort

Selection Sort

2Quick Sort
3Insertion Sort

Consider the following statements.


Statement A: A linked list is a static data structure.
Statement E: An array is a dynamic data structure.

Both statement A and statement B are

true 3 Statement A is true and statement E

is false

Both statement A and statement E are

false 3 Statement A is false and statement

E is true

Predict the output of the following algorithm.


1.Allocate memory for the new node.
2.Assign value to the data field of the new node.
3.Make the next field of the new node point to the first node in the
list.
4.Make the prev field of START point to the new node.
5.Make the prev field of the new node point to NULL.
6.Make START point to the new node.
3 The given algorithm will insert a node between two nodes of a
doubly linked list or at the end of a doubly-linked list.

The given algorithm will insert a node at the end of the doubly-
linked list.

3 The given algorithm will insert a node between two nodes of a


doubly-linked list.

3 The given algorithm will insert a node in the beginning of a


doubly-linked list.
The given document is validated based on the given schema.
Analyze the schema and the document and identify the errors that
will be generated in the validation process.
SCHEMA:
<xsd:scherna xmlns:xsd="http://www.w3.org/2001 /XMLSchema">
<xsd:element narne="STUDENT" type="STUDENTTYPE" />
<xsd:complexType name="STUDENTTYPE"> <xsd:sequence>
<xsd:element name="STUDENTID" type="xsd:nurnehc"/>
<xsd:element name="STUDENTLASTNAME" type="xsd:sthng"/>
<xsd:element narne="GRADE" type="xsd:string"/>
<xsd:element name="STREAM" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
DOCUMENT:
<?xml version="l
.0"?>
<STUDENT>
<ST U DENT LAST N AM E> Lewis </STUDENTLASTNAME>
<STUDENTID> 1 2 </ STUDENTID >
<STREAM> commerce </STREAM>
<GRADE> a </GRADE>
</STUDENT>

3 The declaration of the sequence of elements in the schema does


not match the sequence of elements in the document.

3 The declaration of the attribute datatypes in the schema does not


match the data types in the document.

3 The declaration of the STUDENTTYPE complex element in the


schema is not referenced anywhere in the document.

3 The element STUDENTTYPE should be declared as simple type


instead of complex type.

Harry Smith needs to create a Web site, in which he needs to present


the information in a tree structure. Identify the site structure that
Harry needs to use.

3
Hierarch

y 3
Sequenc

e 3
Web 3
Grid

Which of the following statements will you use to ensure that the
script waits till the XML document gets completely loaded before
continuing with the other code?

3 xmldoc.async = false
xmldoc.readystate =

false 3 xmldoc.async =
true

xmldoc.readystate = 4
The following code is used to generate a comma separated value
listing of the STUDENTS and STUDENTID elements.

<xsl:ternplate rnatch=7">
<xsl:for-each select="STUDENTS/STUDENT">
<xsl:for-each select="STUDENTID">
<xsl:if test ="positionQ = =0"> , </xsl:if>
<xsl:value-of select="/" />
<xsl:value-of select="/" />
</xsl:for-each>
</xsl:for-each>
</xsl:template>

However, the implementation of the code is unsuccessful. Identify


the errors in the code.
The code has the following errors:
1.The test condition is incorrect.
2.The value-of select parameters have been assigned incorrect
values.

3 The code has the following errors:


1.The for-each parameter is assigned an incorrect value.
2.The value-of select parameters have been assigned incorrect
values.

The code has the following errors:


1.The template match parameter is assigned an incorrect value.
2.The value-of select parameters have been assigned incorrect
values.

The code has the following errors:


1.The for-each select parameter is assigned an incorrect value
and test condition is also incorrect.
2.The value-of select parameters have been assigned incorrect
values.

The data about orders is stored in an XML document. Each order is


represented using the Order element. The Order element has an
attribute named ProductlD. You want to extract all Order elements
that have a ProductlD value of 1. Which of the following code
fragments should you use to do so?

2<xsl:ternplate rnatch="Order[ProductlD='l ']">


3<xsl:ternplate select="Order[@ProductlD='l ']7> 3
<xsl:apply-ternplates select="@ProductlD='l " ' f >

<xsl:ternplate rnatch="Order[@ProductlD='l ']">


Consider the following statements:

Statement A: Style sheet is used to transform an XML document into


resultant tree structure, which is then used to render the XML
document to a specific target.
Statement B: Style sheet describes how to present the transformed
information.

Which of the following options is correct with respect to the


preceding statements?

3 Statement A is false and Statement E is true.


Both Statement A and Statement E are false.

Both Statement A and Statement E are True. 3


Statement A is true and statement E is false.

Which of the following is NOT a function provided by XPath?

Boolean functions

3 Character functions
3 Node-set functions
Numeric functions

Which of the following is NOT a valid type of an element content?

Character

Mixed 3
Element 3
Null

In JavaScript, which of the following is a property of the History


object?

history.go hi

story.forward
history.current 3
history.back

Identify the type of content of the EMP element in the following XML
code fragment. <COMPDETAILS> <EMP>Marketing Executive
<EMP_ID>EMPQ01 </EMP_ID>
<EMP_N AME>Robert Wi 11 i am
s</EMP_NAME> </EMP>

</COMPDETAILS

> 3 Element

content 3 Data
content

Mixed content

Em pty
Which of the following statements is correct for XML? Statement A:
XML is a text-based markup language that enables you to store data
in a structured format by using meaningful tags. Statement B: XML
allows you to present data as per the requirements of the
application.

3 Statement A is true and statement E is


false. 3 Statement A is false and statement E
is true. 3 Both the statements are true. 3
Both the statements are false.

Which of the following is NOT an advantage of Electronic Data


Interchange (EDI)?

Flexible business rules

Better customer service

3 Reduced data entry


errors Reduced ordering

time

Jim has to devdelop a code to implement a search operation in a


binary search tree to locate a particular value. He develops a code
according to the following algorithm:
1.Make currentNode point to the root node
2.If currentNode is null:
a. Display "Not found"
b. Exit
3. Compare the value to be searched with the value of currentNode.
Depending on the
result of the comparison, there can be three possibilities:
a. Ifthe value is equal to the value of currentNode:
i. Display "Found"
ii. Exit
b. Ifthe value is less than the value of currentNode:
i. Make currentNode point to its right child
ii. Go to step 2
c. Ifthe value is greater than the value of currentNode:
i. Make currentNode point to its left child
ii. Go to step 2
However, the code does not give the desired output. Identify the
error.

Step 1 is incorrect 3 Step 3 (a)

should come after step 3(c)

Steps 3 (b) and 3 (c) are incorrect. 3


Step 2(a) is incorrect
Predict the output of the following algorithm:
Algorithm: order (root)
1.If (root = NULL): a.
Exit
2.Visit (root)
3.order (left child of root)
4.order (right child of root)
3 The preceding algorithm will traverse a graph by using the EFS
method

3 The preceding algorithm will traverse the tree in the inorder


sequence.

The preceding algorithm will traverse a graph by using the DFS


method

3 The preceding algorithm will traverse the tree in the preorder


sequence

You might also like