Algorithms and Application Programming
Algorithms and Application Programming
Algorithms and
Application Programming
M.Sc. I.T.
Published by :
Think Tanks
Biyani Group of Colleges
While every effort is taken to avoid errors or omissions in this Publication, any mistake or
omission that may have crept in is not intentional. It may be taken note of that neither the
publisher nor the author will be responsible for any damage or loss of any kind arising to
anyone in any manner on account of such errors and omissions.
Preface
am glad to present this book, especially designed to serve the needs of the
students. The book has been written keeping in mind the general weakness in
understanding the fundamental concepts of the topics. The book is self-explanatory and
adopts the Teach Yourself style. It is based on question-answer pattern. The language
of book is quite easy and understandable based on scientific approach.
This book covers basic concepts related to the microbial understandings about
diversity, structure, economic aspects, bacterial and viral reproduction etc.
Any further improvement in the contents of the book by making corrections,
omission and inclusion is keen to be achieved based on suggestions from the readers
for which the author shall be obliged.
I acknowledge special thanks to Mr. Rajeev Biyani, Chairman & Dr. Sanjay Biyani,
Director (Acad.) Biyani Group of Colleges, who are the backbones and main concept
provider and also have been constant source of motivation throughout this Endeavour.
They played an active role in coordinating the various stages of this Endeavour and
spearheaded the publishing work.
I look forward to receiving valuable suggestions from professors of various
educational institutions, other faculty members and students for improvement of the
quality of the book. The reader may feel free to send in their comments and suggestions
to the under mentioned address.
Author
Syllabus
M.Sc.-IT (Sem.-I)
Content
S.No.
Name of Topic
1. Algorithmic Methodology
1.1
Understanding the Problem
1.2
Plan the Logic
1.3
Code the Program
1.4
Pseudocode
1.5
Flowchart
1.6
Time & Space Complexity
2. Conditionals & Looping
2.1
Control Structure
2.2
Looping
3. Abstract Data Types & Recursion
3.1
Basic Data Structure
3.2
Characteristics of Recursion Functions
4. Searching & Sorting Techniques
4.1
Bubble Sort
4.2
Selection Sort
4.3
Insertion Sort
4.4
Merge Sort
4.5
Radix Sort
4.6
Quick Sort
4.7
Binary Sort
4.8
Internal & External Sorting
5. Arrays
5.1
Storage Allocation Functions
5.2
Hashed Allocation Techniques
5.3
Linked Allocation Techniques
28-31
6. String Manipulations
6.1
String Manipulations
6.2
Representations of Strings
32-33
34-36
37-47
48-62
CHAPTER-1
Algorithmic Methodology
Q.1
(2)
(3)
(4)
Q.2
Ans.: An outline of a program, written in a form that can easily be converted into real
programming statements.
Some examples of pseudocode are :
1.
2.
3.
Pseudocode cannot be compiled nor executed, and there are no real formatting
or syntax rules. It is simply one step - an important one - in producing the final
code. The benefit of pseudocode is that it enables the programmer to concentrate
on the algorithms without worrying about all the syntactic details of a particular
programming language. In fact, you can write pseudocode without even
knowing what programming language you will use for the final implementation.
Q.3
10
11
(2)
(3)
(4)
(5)
12
Q.5
(1)
(2)
(3)
(4)
The essentials of what is done can easily be lost in the technical details of
how it is done.
Ans.: The time complexity of a problem is the number of steps that it takes to solve an
instance of the problem as a function of the size of the input (usually measured in
bits), using the most efficient algorithm. To understand this intuitively, consider
the example of an instance that is n bits long that can be solved in n steps. In this
example we say the problem has a time complexity of n. Of course, the exact
number of steps will depend on exactly what machine or language is being used.
To avoid that problem, the Big O notation is generally used (sometimes
described as the "order" of the calculation, as in "on the order of"). If a problem
has time complexity O(n) on one typical computer, then it will also have
complexity O(n) on most other computers, so this notation allows us to
generalize away from the details of a particular computer.
Example : Mowing grass has linear time complexity because it takes double the
time to mow double the area. However, looking up something in a dictionary has
only logarithmic time complexity because a double sized dictionary only has to
be opened one time more (i.e. exactly in the middle, then the problem size is
reduced by half).
The space complexity of a problem is a related concept, that measures the
amount of space, or memory required by the algorithm. An informal analogy
would be the amount of scratch paper needed while working out a problem with
pen and paper. Space complexity is also measured with Big O notation.
13
CHAPTER-2
C
14
if (x == 100)
cout << "x is 100";
If we want more than a single statement to be executed in case that the condition
is true we can specify a block using braces { }:
if (x == 100)
{
cout << "x is ";
cout << x;
}
We can additionally specify what we want to happen if the condition is not
fulfilled by using the keyword else. Its form used in conjunction with if is:
if (condition) statement1 else statement2
For example:
if (x == 100)
cout << "x is 100";
else
cout << "x is not 100";
prints on the screen x is 100 if indeed x has a value of 100, but if it has not -and
only if not- it prints out x is not 100.
The if + else structures can be concatenated with the intention of verifying a
range of values. The following example shows its use telling if the value
currently stored in x is positive, negative or none of them (i.e. zero):
if (x > 0)
cout << "x is positive";
else if (x < 0)
15
Q.2
16
CHAPTER-3
C
Ans.: An abstract data structure is an abstract storage for data defined in terms of the
set of operations to be performed on data and computational complexity for
performing these operations, regardless of the implementation in a concrete data
structure.
Selection of an abstract data structure is crucial in the design of efficient
algorithms and in estimating their computational complexity, while selection of
concrete data structures is important for efficient implementation of algorithms.
Abstract data types (ADT) typically implemented in programming languages (or
their libraries) include :
Complex Number
List
Priority Queue
Queue
Stack
String
Tree
Q.2
17
repeating objects in a self-similar way. For instance, when the surfaces of two
mirrors are almost parallel with each other the nested images that occur are a
form of recursion.
It is a way of thinking about and solving problems. It is, in fact, one of the central
ideas of computer science. [1] Solving a problem using recursion means the
solution depends on solutions to smaller instances of the same problem. [2]
Factorial : A classic example of a recursive procedure is the function used to
calculate the factorial of an integer.
Function Definition : A recurrence relation is an equation that relates later terms
in the sequence to earlier terms[6].
Recurrence relation for factorial:
bn = n * bn-1
b0 = 1
Computing the recurrence relation for n = 4:
b4
= 4 * b3
= 4 * 3 * b2
= 4 * 3 * 2 * b1
= 4 * 3 * 2 * 1 * b0
=4*3*2*1*1
=4*3*2*1
=4*3*2
=4*6
=4*6
= 24
18
CHAPTER-4
C
19
Algorithm needs one whole pass without any swap to know it is sorted.
Third Pass :
(12458)(12458)
(12458)(12458)
(12458)(12458)
(12458)(12458)
Finally, the array is sorted, and the algorithm can terminate.
procedure bubbleSort( A : list of sortable items ) defined as:
for each i in 1 to length(A) do:
for each j in length(A) downto i + 1 do:
if A[ j -1 ] > A[ j ] then
swap( A[ j - 1], A[ j ] )
end if
end for
end for
end procedure
Q.2
(2)
(3)
Repeat the steps above for remainder of the list (starting at the second
position).
Effectively, we divide the list into two parts: the sublist of items already sorted,
which we build up from left to right and is found at the beginning, and the
sublist of items remaining to be sorted, occupying the remainder of the array.
Here is an example of this sort algorithm sorting five elements :
64 25 12 22 11
11 25 12 22 64
11 12 25 22 64
20
Q.3
Ans.: Insertion sort is a simple sorting algorithm, a comparison sort in which the
sorted array (or list) is built one entry at a time. It is much less efficient on large
lists than more advanced algorithms such as quick sort, heap sort, or merge sort,
but it has various advantages :
(1)
Simple to implement.
(2)
(3)
Efficient on data sets which are already substantially sorted: it runs in O(n
+ d) time, where d is the number of inversions.
(4)
stable(does not change the relative order of elements with equal keys)
21
(5)
In- place (only requires a constant amount O(1) of extra memory space)
(6)
22
Q.5
Ans.: In computer science, radix sort is a sorting algorithm that sorts integers by
processing individual digits. Because integers can represent strings of characters
(e.g., names or dates) and specially formatted floating point numbers, radix sort
is not limited to integers.
Most digital computers internally represent all of their data as electronic
representations of binary numbers, so processing the digits of integer
representations by groups of binary digit representations is most convenient.
Two classifications of radix sorts are least significant digit (LSD) radix sorts and
most significant digit (MSD) radix sorts. LSD radix sorts process the integer
representations starting from the least significant digit and move towards the
most significant digit. MSD radix sorts work the other way around.
The integer representations that are processed by sorting algorithms are often
called "keys," which can exist all by themselves or be associated with other data.
LSD radix sorts typically use the following sorting order: short keys come before
longer keys, and keys of the same length are sorted lexicographically. This
coincides with the normal order of integer representations, such as the sequence
1, 2, 3, 4, 5, 6, 7, 8, 9, 10. MSD radix sorts use lexicographic order, which is
suitable for sorting strings, such as words, or fixed-length integer
representations. A sequence such as "b, c, d, e, f, g, h, i, j, ba" would be
lexicographically sorted as "b, ba, c, d, e, f, g, h, i, j". If lexicographic ordering is
used to sort variable-length integer representations, then the representations of
the numbers from 1 to 10 would be output as 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, as if the
shorter keys were left-justified and padded on the right with blank characters to
make the shorter keys as long as the longest key for the purpose of determining
sorted order.
Q.6
23
Ans.: Quicksort sorts by employing a divide and conquer strategy to divide a list into
two sub-lists.
The steps are :
Pick an element, called a pivot, from the list.
Reorder the list so that all elements which are less than the pivot come
before the pivot and so that all elements greater than the pivot come after
it (equal values can go either way). After this partitioning, the pivot is in
its final position. This is called the partition operation.
Recursively sort the sub-list of lesser elements and the sub-list of greater
elements.
The base case of the recursion are lists of size zero or one, which are always
sorted.
In simple pseudocode, the algorithm might be expressed as:
function quicksort(array)
var list less, greater
if length(array) 1
return array
select a pivot value pivot from array
for each x in array
if x < pivot then append x to less
if x > pivot then append x to greater
return concatenate(quicksort(less), pivot, quicksort(greater))
Q.7
Ans.: A binary search algorithm (or binary chop) is a technique for finding a
particular value in a sorted list. It makes progressively better guesses, and closes
in on the sought value by selecting the median element in a list, comparing its
value to the target value, and determining if the selected value is greater than,
less than, or equal to the target value. A guess that turns out to be too high
becomes the new top of the list, and a guess that is too low becomes the new
bottom of the list. Pursuing this strategy iteratively, it narrows the search by a
factor of two each time, and finds the target value.
24
Q.8
25
Ans.: An internal sort is any data sorting process that takes place entirely within the
main memory of a computer. This is possible whenever the data to be sorted is
small enough to all be held in the main memory. For sorting larger datasets, it
may be necessary to hold only a chunk of data in memory at a time, since it wont
all fit. The rest of the data is normally held on some larger, but slower medium,
like a hard-disk. Any reading or writing of data to and from this slower media
can slow the sortation process considerably. This issue has implications for
different sort algorithms.
Consider a Bubblesort, where adjacent records are swapped in order to get them
into the right order, so that records appear to 'bubble' up and down through the
dataspace. If this has to be done in chunks, then when we have sorted all the
records in chunk 1, we move on to chunk 2, but we find that some of the records
in chunk 1 need to 'bubble through' chunk 2, and vice versa (i.e., there are
records in chunk 2 that belong in chunk 1, and records in chunk 1 that belong in
chunk 2 or later chunks). This will cause the chunks to be read and written back
to disk many times as records cross over the boundaries between them, resulting
in a considerable degradation of performance. If the data can all be held in
memory as one large chunk, then this performance hit is avoided.
On the other hand, some algorithms handle external sorting rather better. A
Merge sort breaks the data up into chunks, sorts the chunks by some other
algorithm (maybe bubblesort or Quick sort) and then recombines the chunks two
by two so that each recombined chunk is in order. This approach minimises the
number or reads and writes of data-chunks from disk, and is a popular external
sort method.
26
CHAPTER-5
C
Arrays
Q.1
Ans.: Sizeof & Malloc : The sizeof operator returns the size in bytes of its operand.
Whether the result of sizeof is unsigned int or unsigned long is implementation
definedwhich is why the declaration of malloc above ducked the issue by
omitting any parameter information; normally you would use the stdlib.h header
file to declare malloc correctly. Here is the last example done portably :
#include <stdlib.h>
/* declares malloc() */
float *fp;
fp = (float *)malloc(sizeof(float));
The operand of sizeof only has to be parenthesized if it's a type name, as it was in
the example. If you are using the name of a data object instead, then the
parentheses can be omitted, but they rarely are.
#include <stdlib.h>
int *ip, ar[100];
ip = (int *)malloc(sizeof ar);
In the last example, the array ar is an array of 100 ints; after the call to malloc
(assuming that it was successful), ip will point to a region of store that can also
be treated as an array of 100 ints.
The fundamental unit of storage in C is the char, and by definition
sizeof(char)
is equal to 1, so you could allocate space for an array of ten chars with
malloc(10)
while to allocate room for an array of ten ints, you would have to use
malloc(sizeof(int[10]))
27
If malloc can't find enough free space to satisfy a request it returns a null pointer
to indicate failure. For historical reasons, the stdio.h header file contains a
defined constant called NULL which is traditionally used to check the return
value from malloc and some other library functions. An explicit 0 or (void *)0
could equally well be used.
Calloc and Realloc : There are two additional memory allocation functions,
Calloc() and Realloc(). Their prototypes are given below:
void *calloc(size_t num_elements, size_t element_size};
void *realloc( void *ptr, size_t new_size);
Malloc does not initialise memory (to zero) in any way. If you wish to initialise
memory then use calloc. Calloc there is slightly more computationally expensive
but, occasionally, more convenient than malloc. Also note the different syntax
between calloc and malloc in that calloc takes the number of desired elements,
num_elements, and element_size, element_size, as two individual arguments.
Thus to assign 100 integer elements that are all initially zero you would do:
int *ip;
ip = (int *) calloc(100, sizeof(int));
Realloc is a function which attempts to change the size of a previous allocated
block of memory. The new size can be larger or smaller. If the block is made
larger then the old contents remain unchanged and memory is added to the end
of the block. If the size is made smaller then the remaining contents are
unchanged.
If the original block size cannot be resized then realloc will attempt to assign a
new block of memory and will copy the old block contents. Note a new pointer
(of different value) will consequently be returned. You must use this new value.
If new memory cannot be reallocated then realloc returns NULL.
Thus to change the size of memory allocated to the *ip pointer above to an array
block of 50 integers instead of 100, simply do:
ip = (int *) calloc( ip, 50);
Q.2
Ans.: Hashing has a worst-case behavior that is linear for finding a target, but with
some care, hashing can be dramatically fast in the average-case. Hashing also
28
// the student ID
// phone number
29
30
CHAPTER-6
C
String Manipulations
Q.1
main()
{
char arr[]=Colleges;
31
int len1,len2;
len1=strlen(arr);
len2=strlen(Girls collge);
printf(String = %s length = %d,arr,len1);
printf(String = %s length = %d,Girls college,len2);
}
2)
main()
{
char source[]=Biyani College;
char target[20];
strcpy(target,source);
printf(String is : %s,target);
}
32
CHAPTER-7
C
Ans.: A text file (sometimes spelled "textfile") is a kind of computer file that is
structured as a sequence of lines. A text file exists within a computer file system.
The end of a text file is often denoted by placing one or more special characters,
known as an end-of-file marker, after the last line in a text file.
"Text file" refers to a type of container, while plain text refers to a type of content.
Text files can contain plain text, but they are not limited to such.
Because of their simplicity text files are commonly used for storage of
information. They avoid some of the problems encountered with other file
formats, such as endianness, padding bytes, or differences in the number of bytes
in a machine word. Further, when data corruption occurs in a text file, it is often
easier to recover and continue processing the remaining contents. A
disadvantage of text files is that they usually have a low entropy, meaning that
the information occupies more storage than is strictly necessary.
A binary file is a computer file which may contain any type of data, encoded in
binary form for computer storage and processing purposes; for example,
computer document files containing formatted text. Many binary file formats
contain parts that can be interpreted as text; binary files that contain only textual
data - without, for example, any formatting information - are called plain text
files. In many cases, plain text files are considered to be different from binary
files because binary files are made up of more than just plain text. When
downloading, a completely functional program without any installer is also often
called program binary, or binaries (as opposed to the source code).
Binary files are usually thought of as being a sequence of bytes, which means the
binary digits (bits) are grouped in eights. Binary files typically contain bytes that
are intended to be interpreted as something other than text characters. Compiled
33
34
35
CHAPTER-8
C
Ans.: A system call is a request made by any arbitrary program to the operating
system for performing tasks -- picked from a predefined set -- which the said
program does not have required permissions to execute in its own flow of
execution. Most operations interacting with the system require permissions not
available to a user level process, i.e. any I/O performed with any arbitrary device
present on the system or any form of communication with other processes
requires the use of system calls.
The fact that improper use of the system can easily cause a system crash
necessitates some level of control. The design of the microprocessor architecture
on practically all modern systems (except some embedded systems) offers a
series of privilege levels -- the (low) privilege level in which normal applications
execute limits the address space of the program so that it cannot access or modify
other running applications nor the operating system itself. It also prevents the
application from using any system devices (e.g. the frame buffer or network
devices). But obviously any normal application needs these abilities; thus it can
call the operating system. The OS executes at the highest level of privilege and
allows the applications to request services via system calls, which are often
implemented through interrupts. If allowed, the system enters a higher privilege
level, executes a specific set of instructions which the interrupting program has
no direct control over, then returns control to the former flow of execution. This
concept also serves as a way to implement security.
With the development of separate operating modes with varying levels of
privilege, a mechanism was needed for transferring control safely from lesser
privileged modes to higher privileged modes. Less privileged code could not
simply transfer control to more privileged code at any arbitrary point and with
any arbitrary processor state. To allow it to do so would allow it to break
36
37
O_CREAT
This flag will make open to create the file if it does not exist, or
overwrite an existing one.
O_EXCL
When this flag is used with O_CREAT, it avoids the overwriting
behaviour.
O_NONBLOCK
Operations on the file descriptor will return control to the process
immediately instead of waiting to finish.
the mode_t argument is optional, and is relevant only when creating a new
file. It indicates the file permissions for the newly created file.
2)
3)
4)
38
Q.2
5)
6)
39
40
41
Using a File Mapping for IPC : File mapping enables a process to treat the
contents of a file as if they were a block of memory in the process's address
space. The process can use simple pointer operations to examine and modify the
contents of the file. When two or more processes access the same file mapping,
each process receives a pointer to memory in its own address space that it can
use to read or modify the contents of the file. The processes must use a
synchronization object, such as a semaphore, to prevent data corruption in a
multitasking environment.
You can use a special case of file mapping to provide named shared memory
between processes. If you specify the system swapping file when creating a filemapping object, the file-mapping object is treated as a shared memory block.
Other processes can access the same block of memory by opening the same filemapping object.
File mapping is quite efficient and also provides operating-systemsupported
security attributes that can help prevent unauthorized data corruption. File
mapping can be used only between processes on a local computer; it cannot be
used over a network.
Using a Mailslot for IPC : Mailslots provide one-way communication. Any
process that creates a mailslot is a mailslot server. Other processes, called mailslot
clients, send messages to the mailslot server by writing a message to its mailslot.
Incoming messages are always appended to the mailslot. The mailslot saves the
messages until the mailslot server has read them. A process can be both a
mailslot server and a mailslot client, so two-way communication is possible
using multiple mailslots.
A mailslot client can send a message to a mailslot on its local computer, to a
mailslot on another computer, or to all mailslots with the same name on all
computers in a specified network domain. Messages broadcast to all mailslots on
a domain can be no longer than 400 bytes, whereas messages sent to a single
mailslot are limited only by the maximum message size specified by the mailslot
server when it created the mailslot.
Using Pipes for IPC : There are two types of pipes for two-way communication:
anonymous pipes and named pipes. Anonymous pipes enable related processes to
transfer information to each other. Typically, an anonymous pipe is used for
redirecting the standard input or output of a child process so that it can exchange
data with its parent process. To exchange data in both directions (duplex
operation), you must create two anonymous pipes. The parent process writes
data to one pipe using its write handle, while the child process reads the data
from that pipe using its read handle. Similarly, the child process writes data to
42
Q.3
What is Indexing? What are the different type of Indexes used in File
Organization?
Ans.: Indexing :
43
Index file stores each value of the index field along with pointer: pointer(s)
to block(s) that contain record(s) with that field value or pointer to the
record with that field value :
<Indexing Field, Pointer>
In oracle, the pointer is called RowID which tells the DBMS where the row
(record) is located (by file, block within that file, and row within the
block).
Index file much smaller than the data file => searching will be fast.
Types of Indexes :
Dense : An entry in the index file for each record of the data file.
Sparse : only some of the data records are represented in the index,
often one index entry per block of the data file.
44
45
CHAPTER-9
C
Ans.:
Specifying logical formulae is often more natural than filling in tables (i.e.,
arbitrary constraints).
It is easier to check and debug formulae than tables.
We can exploit the Boolean nature for efficient reasoning.
We need a language for asking queries that may be more complicated
than asking for the value of one variable.
It is easy to incrementally add formulae.
It can be extended to infinitely many variables (using logical
quantification).
This is a starting point for more complex logics (e.g., first-order logic) that
go beyond CSPs.
Syntax of Predicate Logic : Propositional logic is fairly powerful but we must
add variables and quantification to be able to reason about objects in atoms and
express properties of a set of objects without listing the atom corresponding to
each object.
We shall adopt the Prolog convention that variables have an initial capital letter.
(This is contrary to many Mathematical Logic books where variables are lower
case and constants have an initial capital.)
46
C.cute(C))
loves(misspiggy, kermit)
...
Contrast this with the infinite set of positive integers and the sentence
N.[odd(N)
even(N)]
(there exists).
X.loves(misspiggy, X)
This allows X to range over all the objects and asserts that Miss Piggy loves (at
least) one of them. Similarly
XY.loves(X, Y)
asserts that there is at least one loving couple (or self-loving object).
Note: We shall be using First Order Predicate Logic where quantified variables
range over object constants only. We are defining Second Order Predicate Logic
if we allow quantified variables to range over functions or predicates as well; e.g.
X.loves(misspiggy,
voiceof(kermit))
X(kermit))
includes
loves(misspiggy,
47
in our domain.
:
holds in a model iff there is some object
holds.
Example: Available Objects affects Quantification
If misspiggy is the only object in our domain then
ugly(misspiggy)
X.ugly(X)
beautiful(misspiggy) is equivalent to
beautiful(X)
If there were other objects then there would be more atoms and so the set of
models would be larger; e.g. with objects misspiggy and kermit the possible
models are all combinations of the atoms ugly(misspiggy), beautiful(misspiggy)
ugly(kermit), beautiful(kermit). Now the 2 sentences are no longer equivalent.
1.
2.
Q.2
48
p q
Q.3
(1)
( pq ) p q
(2)
( pq ) p q
49
Ans.: Formal Logic : Formal logic is a set of rules for making deductions that seem self
evident. Syllogisms like the following occur in every day conversation.
All humans are mortal.
Socrates is a human.
Therefore Socrates is mortal.
Mathematical logic formalizes such deductions with rules precise enough to
program a computer to decide if an argument is valid.
This is facilitated by representing objects and relationships symbolically. For
example we might use for the set of humans,
for the set of mortal creatures
and
object
is the same as
are true or is false.
50
false
false
false
false
true
false
true
false
false
true
true
true
OR
AAB
false
false
false
false
true
true
true
false
true
true
true
true
NOT A
false
true
true
false
Table 3.2: Evaluating a logical expression
symbolA B CDE F
truth value
true
true
false
true
true
false
expression evaluation
false
51
true
false
false
false
true
true
The order in which the logical operations are done is important. The rules for this
are called precedence. First do NOT then AND finally OR. If the NOT sign
extends over a subexpression, the subexpression is evaluated and the NOT
operation is applied to that result. In this example at the first level we can
evaluate
and
. At subsequent levels the part of the expression
evaluated at higher levels in in smaller type.
Q.4
What are the different proofs that are already existed in Artificial Intelligence?
52
53
(iii)
(iv)
54
(vi)
55
56
57
semantic, pragmatic, and discourse processing. While the holy grail of full
natural language understanding remains a distant dream, here as
elsewhere in AI, piecemeal progress is being made and finding
application in grammar checkers; information retrieval and information
extraction systems; natural language interfaces for games, search engines,
and question-answering systems; and even limited machine translation
(MT).
Q.5
What are the various Rules of Inference & Resolution Proofs in the field of
Artificial Intelligence?
Resolution Proofs :
o
Proof is exponential.
Theorem proving is suitable for certain problems, but not for all problems.
MCQs:
58
Set-I
1.
( )
2.
The time factor when determining the efficiency of an algorithm is measured by:
(a)
Counting microseconds
(b)
Counting the number of key operations
(c)
Counting the number of statement
(d)
Counting the Kilobytes of algorithm
( )
3.
4.
The space factor when determining the efficiency of algorithm is measured by:
(a)
Counting the maximum memory needed by the algorithm
(b)
Counting the minimum memory needed by the algorithm
(c)
Counting the average memory needed by the algorithm
(d)
Counting the maximum disk space needed by the algorithm
( )
( )
A queue is a :
(a)
Sequential Organization of data
(b)
Listing of data
(c)
Indexing of data
(d)
None of the above
( )
5.
6.
7.
(d)
8.
9.
59
( )
O (log n)
O (n log n)
( )
O (log n)
O (n log n)
( )
10.
Each array declaration need not give, implicitly or explicitly, the information about: (a)
the name of array
(b)
the data type of array
(c)
the first data from the set to be stored
(d)
the index set of the array
( )
11.
( )
( )
( )
12.
13.
14.
15.
60
16.
( )
17.
18.
( )
( )
( )
( )
19.
20.
21.
(b)
(d)
One
Three
22.
Which of the following abstract data types are not used by Integer Abstract Data Type
group?
(a)
Short
(b)
Int
(c)
Float
(d)
Long
( )
23.
24.
25.
26.
27.
61
( )
( )
( )
( )
28.
29.
30.
Liner array is a :
(a)
List of finite number n of heterogeneous data elements
(b)
List of finite number, n of homogenous data elements
( )
62
31.
32.
33.
34.
35.
( )
How many null branches are there in a binary tree with 20 nodes:
(a)
Zero
(b)
Thirty
(c)
Twenty one
(d)
None of the above
( )
( )
( )
( )
( )
36.
37.
(d)
38.
39.
40.
63
( )
Data items that are divided into sub items are called:
(a)
Elementary item
(b)
Group item
(c)
(a) and (b) Both
(d)
None of the above
( )
( )
Answer Key
1. (c)
2. (a)
3. (b)
4. (a)
5. (a)
6. (a)
7. (b)
8. (b)
9. (c)
10. (c)
11. (d)
12. (b)
13. (d)
14. (a)
15. (b)
16. (b)
17. (b)
18. (a)
19. (b)
20. (b)
21. (d)
22. (c)
23. (c)
24. (c)
25. (a)
26. (a)
27. (c)
28. (a)
29. (b)
30. (b)
31. (c)
32. (a)
33. (b)
34. (b)
35. (b)
36. (a)
37. (a)
38. (a)
39. (a)
40. (a)
__________
64
65
Set-II
1.
2.
3.
4.
5.
6.
7.
8.
9.
( )
( )
(b)
(d)
O (n)
O (n2)
( )
(b)
(d)
Queue
Graph
( )
(b)
(d)
0
1
( )
( )
Array is:
(a)
Linear Data Structure
(b)
Non Linear Data Structure
(c)
Complex Data Structure
(d)
None of the above
( )
( )
If char * name = Dishita",; statement is executed successfully, then what will be the value
of * name?
66
10.
11.
12.
13.
14.
15.
D
Dishita
Garbage
None of the above
( )
( )
What is the minimum number of field with each node of doubly linked list?
(a)
1
(b)
2
(c)
3
(d)
4
( )
( )
(b)
(d)
( )
( )
( )
16.
17.
A linear list of elements in which deletion can be done from one end and insertion can
take place only at the other end is known is:
(a)
Queue
(b)
Stacks
(c)
Tree
(d)
Branch
67
( )
18.
19.
( )
( )
( )
( )
20.
21.
22.
23.
Which method of traversal does not use stack to hold nodes that are waiting to be
processed >
(a)
Breadth First
(b)
Depth first
(c)
D-search
(d)
None of the above
( )
24.
( )
68
25.
( )
26.
A balanced binary tree is a binary tree in which the height of the two subtree of every
node never differs by more than:
(a)
2
(b)
1
(c)
3
(d)
None of the above
( )
27.
( )
28.
Which of the following abstract data types can be used to represent a many to many
relation?
(a)
Tree, only
(b)
Plex, only
(c)
Graph, only
(d)
Both B and A
( )
29.
30.
31.
(b)
(d)
( )
( )
A technique which collects all detected space in free storage list is called:
(a)
Static memory allocation
(b)
Garbage collection
(c)
Dynamic memory
(d)
None of the above
( )
32.
33.
34.
35.
36.
37.
38.
39.
40.
69
( )
( )
( )
n +1 nodes
log2 n nodes
( )
( )
( )
(b)
(d)
Pendant vertex
Null vertex
( )
Traversing means:
(a)
Accessing and Processing each record exactly once
(b)
Arranging and data in some given order
(c)
Finding the location of the record with a given key
(d)
None of the above
( )
Stack is:
(a)
Static data structure
(b)
In built data structure
(c)
Dynamic data structure
70
( )
Answer Key
1. (a)
2. (b)
3. (c)
4. (a)
5. (b)
6. (c)
7. (a)
8. (a)
9. (a)
10. (b)
11. (c)
12. (a)
13. (c)
14. (a)
15. (a)
16. (b)
17. (a)
18. (b)
19. (a)
20. (c)
21. (c)
22. (b)
23. (a)
24. (a)
25. (a)
26. (b)
27. (c)
28. (c)
29. (d)
30. (b)
31. (b)
32. (b)
33. (b)
34. (c)
35. (d)
36. (d)
37. (b)
38. (a)
39. (a)
40. (b)
________
71
Set- III
1.
2.
3.
space used
None
( )
( )
A node contains :
(a)
Information and link field
(b)
Information and data item
(c)
Address and link field
(d)
All of the above
( )
4.
Operating system periodically collect all the deleted space into the free storage list is
called:
(a)
Fragmentation
(b)
Garbage collection
(c)
Overflow
(d)
Underflow
( )
5.
Overflow means:
(a)
NO empty space available
(b)
No item is available
(c)
Error
(d)
none
( )
( )
6.
7.
(b)
(d)
( )
72
8.
Data structure that take insertion and deletion only at beginning or the end, not in the
middle:
(a)
Linked list and linear array
(b)
Stack and queues
(c)
Stack and linked list
(d)
Linked list and queues
( )
9.
10.
11.
12.
13.
(b)
(d)
PUSH
LIFO
( )
( )
(b)
(d)
CD
+AB
( )
( )
( )
(b)
(d)
log n
n1
14.
A ..is a linear list of elements in which deletion can take place only at one
end and insertion at other end?
(a)
Stack
(b)
Linked list
(c)
Queue
(d)
Tree
( )
15.
16.
( )
(b)
Stack
(c)
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
Queue
(d)
Tree
73
( )
( )
( )
( )
(b)
(d)
Stack
Tree
( )
(b)
(d)
Stack
Queue
( )
(b)
(d)
G = (B,C)
G = (A,C)
( )
(b)
(d)
O (n log2 n)
O (n)
( )
(b)
(d)
O (n)
None
( )
( )
( )
(b)
(d)
7
None
74
27.
28.
( )
(a)
(c)
29.
30.
31.
32.
33.
Graph
Tree
(b)
(d)
Multigraph
Weighted graph
( )
BCE
BAED
( )
(b)
(d)
CDEA
None
( )
(b)
(d)
3
1
( )
(b)
(d)
BAC
CDE
( )
(b)
(d)
ABDECF
None
( )
(a)
(c)
34.
DBEACF
DEBFCA
(a)
(c)
35.
36.
37.
38.
39.
40.
DBEACF
DEBFCA
75
(b)
(d)
DBEACF
None
( )
DBEACF
NONE
( )
( )
( )
Flow lines
None
( )
Recursion means:
(a)
function calling itself
(c)
Null function
(b)
(d)
Subroutine
None
( )
Root node
None
( )
Answer Key
1. c)
2. (b)
3. (a)
4. (b)
5. (a)
6. (a)
7. (b)
8. (b)
9. (b)
10. (b)
11. (d)
12. (b)
13. (a)
14. (c)
15. (b)
16. (d)
17. (a)
18. (a)
19. (a)
20. (d)
21. (c)
22. (a)
23. (a)
24. (a)
25. (a)
26. (a)
27. (d)
28. (a)
29. (b)
30. (a)
31. (c)
32. (a)
33. (b)
34. (a)
35. (a)
36. (c)
37. (d)
38. (c)
39. (a)
40. (a)
76
77
Set -IV
1.
2.
( )
( )
3.
Which
(a)
(b)
(c)
(d)
of the following sorting algorithm is based on the 'Divide and Conquer' paradigm?
Quick sort
Merge Sort
Heap Sort
All of the above
( )
4.
( )
5.
6.
The initial configuration of a queue is P,Q, R,S (P is the front end). To the configuration
S,R,Q one needs a minimum of:
(a)
2 addition and 3 deletion
(b)
3 addition and 3 deletion
(c)
3 addition and 4 deletion
(d)
3 addition and 2 deletion
( )
7.
The depth n of the complete binary tree in with a nodes is gives by:
(a)
log2 (n +1) 1
(b)
log2 n+1
(c)
log2 (n1) + 1
(d)
log2 n
( )
78
8.
( )
9.
One of the more popular balanced trees was introduced in 1962 by adelson-velski and
Landis is known as:
(a)
AVL Tree
(b)
B Tree
(c)
M-way search tree
(d)
None of the above
( )
10.
(a)
(c)
11.
Binary tree
Binary search tree
( )
e2
12.
(b)
(d)
e3
e4
(a)
(b)
(c)
(d)
e5
Directed graph
Multigraph
AVL tree
None of the above
( )
The operation of finding the location of a given item in a collection of items is called: (a)
Sorting
(b) Searching
(c)
Listing
(d)
None of the above
( )
13.
14.
15.
79
( )
( )
( )
16.
The notation in which operation symbol is placed before its two operands, is called: (a)
Infix notation
(b)
Polish notation
(c)
Suffix notation
(d)
None of the above
( )
17.
( )
18.
When a called function in turn calls another function a process of chaining occurs. A
special case of this process, where a function calls itself is called.
(a)
Recursion
(b)
Deletion
(c)
Insertion
(d)
Overloading
( )
19.
( )
( )
20.
80
21.
22.
( )
( )
(b)
(d)
Null string
Both A and B
23.
The variables which can be accessed only within a particular program of subprogram are
known as:
(a)
Local variables
(b)
Global variable
(c)
Auto variables
(d)
External variables
( )
24.
( )
( )
( )
( )
25.
26.
27.
28.
81
1
2
(a)
(c)
Directed graph
Unconnected graph
(b)
(d)
Undirected graph
AVL tree
( )
29.
A special list maintained with the linked list in memory, which consists of unused
memory cells and has its own pointer is called:
(a)
List of available space
(b)
Free storage list
(c)
Free pool
(d)
All of the above
( )
30.
( )
31.
What is the minimum number of fields with each elements of a doubly linked list?
(a)
1
(b)
2
(c)
3
(d)
4
( )
32.
float
ch
( )
33.
The running time T (n), where 'n' is the input size of recursive algorithm is given as
follows: T (n) = c +T (n 1 ;, if n >1, )
D =1, if n<_1
The order of algorithm is:
(a)
n2
(b)
n
(c)
n3
(d)
nn
( )
34.
If we use a 16-bit word length, the maximum size of the integer value is:
(a)
2161
(b)
2151
(c)
2191
(d)
215
35.
( )
A linear list of elements in which deletions can take place only at one end and insertions
can take place only at other end is called:
(a)
Stack
(b)
Queue
(c)
Deque
(d)
Linked list
( )
82
36.
Sometimes new data are to be inserted into a data structure but there is no available space
i.e. the free storage list is empty. This situation is usually called:
(a)
Underflow
(b)
Overflow
(c)
Overflow
(d)
None of the above
( )
37.
( )
( )
( )
A header list where the last node points back to the header node is called :
(a)
A grounded header list
(b)
A circular header list
(c)
Both (A) and (B)
(d)
None of the above
( )
38.
39.
40.
(b)
(d)
Answer Key
1. (a)
2. (a)
3. (a)
4. (d)
5. (b)
6. (a)
7. (b)
8. (a)
9. (a)
10. (a)
11. (b)
12. (b)
13. (a)
14. (a)
15. (a)
16. (b)
17. (b)
18. (a)
19. (a)
20. (a)
21. (b)
22. (d)
23. (a)
24. (d)
25. (a)
26. (c)
27. (c)
28. (b)
29. (d)
30. (d)
31. (c)
32. (c)
33. (a)
34. (a)
35. (b)
36. (b)
37. (b)
38. (a)
39. (a)
40. (b)
________
83
SET-V
1.
What is the term used for describing the judgmental or commonsense part of problem
solving?
A.
Heuristic
B.
Critical
C.
Value based
D.
Analytical
E.
None of the above
Answer: Option A
2.
What stage of the manufacturing process has been described as "the mapping of function
onto form"?
A.
Design
B.
Distribution
C.
project management
D.
field service
E.
None of the above
Answer: Option A
84
3.
4.
5.
6.
7.
want it to
D.
E.
85
pick-and-place control
None of the above
Answer: Option B
8.
9.
DEC advertises that it helped to create "the world's first expert system routinely used in
an industrial environment," called XCON or:
A.
PDP-11
B.
Rl
C.
VAX
D.
MAGNOM
E.
None of the above
Answer: Option B
10.
11.
Seymour Papert of the MIT AI lab created a programming environment for children
called:
A.
BASIC
B.
LOGO
C.
MYCIN
D.
FORTRAN
E.
None of the above
Answer: Option B
access was:
86
12.
13.
The original LISP machines produced by both LMI and Symbolics were based on
research performed at:
A.
CMU
B.
MIT
C.
Stanford University
D.
RAMD
E.
None of the above
Answer: Option B
14.
15.
Weak AI is
A.
the embodiment of human intellectual capabilities within a computer.
B.
a set of computer programs that produce output that would be considered to
reflect intelligence if it were generated by humans.
C.
the study of mental faculties through the use of mental models implemented on a
computer.
D.
All of the above
E.
None of the above
Answer: Option C
16.
87
D.
(setq y 'x')
E.
None of the above
Answer: Option D
_
17.
18.
In LISP, the function returns t if <object> is a CONS cell and nil otherwise:
A.
(cons <object>)
B.
(consp <object>)
C.
(eq <object>)
D.
(cous = <object>)
E.
None of the above
Answer: Option B
19.
If a robot can alter its own trajectory in response to external conditions, it is considered to
be:
A.
intelligent
B.
mobile
C.
open loop
D.
non-servo
E.
None of the above
Answer: Option A
20.
One of the leading American robotics centers is the Robotics Institute located at:
A.
CMU
B.
MIT
C.
RAND
D.
SRI
E.
None of the above
Answer: Option A
21.
88
22.
Nils Nilsson headed a team at SRI that created a mobile robot named:
A.
Robitics
B.
Dedalus
C.
Shakey
D.
Vax
E.
None of the above
Answer: Option C
23.
24.
The new organization established to implement the Fifth Generation Project is called:
A.
ICOT (Institute for New Generation Computer Technology)
B.
MITI (Ministry of International Trade and Industry)
C.
MCC (Microelectronics and Computer Technology Corporation)
D.
SCP (Stategic Computing Program)
E.
None of the above
Answer: Option A
25.
1.
2.
89
( )
( )
3.
For a sequential search, the average number of comparisons for a file with records is:
(a)
(n+1)/2
(b)
log2 n
(c)
n2
(d)
n/2
( )
4.
A data structure, in which an element is added and removed only from one end is known
is:
(a)
Queue
(b)
Stack
(c)
Array
(d)
None of the above
( )
5.
( )
( )
6.
7.
What is the minimum number of fields with each element of a doubly linked list?
(a)
1
(b)
2
(c)
3
(d)
4
( )
8.
90
9.
An array
A union
A structure
None of the above
( )
( )
10.
Which of the following sorting algorithm is based on the idea of "Divide" and conquer?
(a)
Merge sort
(b)
Heap sort
(c)
Both B and A
(d)
None of the above
( )
11.
12.
13.
Bubble search
Selection search
( )
( )
( )
14.
The five items A B C D AND E are pushed in a stack, one after the another starting from
A. The stack is popped four times and each elements is inserted in a queue. The two
element are deleted from the queue and pushed back on the stack. Now one item is
popped from the stack. The popped items is:
(a)
A
(b)
B
(c)
C
(d)
D
( )
15.
(c)
(d)
16.
17.
91
( )
( )
( )
Binary Search
Insertion
18.
In which tree for every node the height of its left and right sub tree differ at last by one?
(a)
Binary search tree
(b)
AVL tree
(c)
Complete Tree
(d)
None of the above
( )
19.
( )
20.
When of the following in turn calls another function a process of 'chaining' occurs. A
special case of this process, where a function calls itself is called:
(a)
Recursion
(b) Delection
(c)
Insertion
(d)
Overloading
( )
21.
Which of the following abstract data types can be used to represent a many to many
relation:
(a)
Tree
(b)
Graph
(c)
Both A and B
(d)
None of the above
( )
22.
In the balanced binary tree given below, how many nodes become unbalanced when a
node inserted as a child of the node "g"
a
e
b
d
(a)
(b)
92
23.
(d)
( )
( )
24.
If we use a 16- bit word length, the size of the integer value is limited to the range:
(a)
26 to 261
(b)
210 to 2101
(c)
215
(d)
215
( )
25.
26.
If there are n vertices in the graph then how many edges are needed to construct a
minimum spanning tree?
(a)
(c)
27.
28.
( )
n
n1
(b)
(d)
n+1
n2
( )
( )
(a)
(b)
(c)
(d)
(A + (B * C)) (D * E)
(A+B)* C DE
ABC +*(D*E)
None of the above
( )
29.
30.
31.
93
( )
( )
(a)
(c)
32.
Directed Graph
Unconnected graph
(b)
(d)
Undirected graph
AVL tree
( )
( )
33.
A linear list in which elements can be added or removed at either end but not in the
middle is called:
(a)
Queue
(b)
Dequeue
(c)
Stack
(d)
Linked list
( )
34.
Queue
Linked
( )
O (n log2 n)
O (log2n)
( )
35.
36.
(b)
(d)
94
37.
38.
Bubble sort
Quick sort
All of the above
( )
( )
( )
39.
When new data are to be inserted into a data structure but there is no available space, this
situation is called :
(a)
Overflow
(b)
Underflow
(c)
Compaction
(d)
Fragmentation
( )
40.
The variables which can be accessed by all modules in a program, are known as:
(a)
Local variables
(b)
Internal variables
(c)
Global variables
(d)
Auto variables
( )
Answer Key
1. (b)
2. (b)
3. (d)
4. (b)
5. (c)
6. (b)
7. (c)
8. (a)
9. (c)
10. (d)
11. (a)
12. (c)
13. (a)
14. (d)
15. (c)
16. (a)
17. (d)
18. (b)
19. (d)
20. (a)
21. (b)
22. (b)
23. (d)
24. (a)
25. (c)
26. (c)
27. (d)
28. (a)
29. (a)
30. (d)
31. (a)
32. (c)
33. (b)
34. (b)
35. (b)
36. (d)
37. (d)
38. (a)
39. (a)
40. (c)
_________
95
A Case Study
Small world Notion.
The mathematical model that we use for studying the nature of pairwise connections among
entities is known as the graph. Some graphs exhibit a specific property known as the small-world
phenomenon. You may be familiar with this property, which is sometimes known as six degrees
of separation. It is the basic idea that, even though each of us has relatively few acquaintances,
there is a relatively short chain of acquaintances (the six degrees of separation) separating us
from one another.
Graphs.
A graph is comprised of a set of vertices and a set of edges. Each edge represents a connection
between two vertices. The list below suggests the diverse range of systems where graphs are
appropriate starting points for understanding structure.
GRAPH
VERTICES
EDGES
Communication
telephones, computers
Circuits
wires
Mechanical
joints
Hydraulic
pipelines
Financial
stocks, currency
transactions
Transportation
Scheduling
tasks
precedence constraints
Software systems
functions
function calls
Internet
web pages
hyperlinks
Games
board positions
legal moves
Social networks
proteins
protein-protein interactions
96
genes
regulatory interactions
Neural networks
neurons
synapses
Infectious disease
people
infections
transmission stations
cable
Chemical compounds
molecules
chemical bonds
Graph implementation.
Program Graph.java implements this API. Its internal representation is a symbol table of sets: the
keys are vertices and the values are the sets of neighbors (the vertices adjacent to the key) This
97
representation uses the two data types ST.java and SET.java that we introduced in Section 4.4.
Our implementation has three important properties:
Clients can efficiently iterate through the graph vertices.
Clients can efficiently iterate through a vertex's neighbors.
Space usage is proportional to the number of edges.
Performer-movie graphs.
The performer-movie graph includes a vertex for each performer and movie and an edge between
a performer and a movie if the performer appeared in the movie.
98
We provide a number of sample data files. Each line in a file consists of a movie, followed by a
list of peformers that appeared in the movie, separated by the / delimiter.
FILE
DESCRIPTION
cast.06.txt
8780
84236
103815
52195
348497
606531
cast.G.txt
1288
21177
28485
cast.PG.txt
3687
74724
116715
2538
70325
103265
21861
280624
627061
14938
139861
266485
99
cast.rated.txt
popular movies
4527
122406
217603
cast.all.txt
285462
933864
3317266
Program IndexGraph.java takes a query which is the name of a movie (in which case it prints the
list of performers that appear in that movie) or the name of a performer (in which case it prints
the lst of movies in which that performer has appeared).
100
PathFinder.java implements the API using a classic algorithm known as breadth-first search.
Degrees of separation.
One of the classic applications of shortest-paths algorithms is to find the degrees of separation of
individuals in social networks. To fix ideas, we discuss this application in terms of a recently
popularized pastime known as the Kevin Bacon game, which uses the movie-performer graph
that we just considered. Kevin Bacon is a prolific actor who appeared in many movies. We
assign every performer who has appeared in a movie a Bacon number: Bacon himself is 0, any
performer who has been in the same cast as Bacon has a Kevin Bacon number of 1, any other
performer (except Bacon) who has been in the same cast as a performer whose number is 1 has a
Kevin Bacon number of 2, and so forth. For example, Meryl Streep has a Kevin Bacon number
of 1 because she appeared in The River Wild with Kevin Bacon. Nicole Kidman's number is 2:
although she did not appear in any movie with Kevin Bacon, she was in Cold Mountain with
Donald Sutherland, and Sutherland appeared in Animal House with Kevin Bacon.
Given the name of a performer, the simplest version of the game is to find some alternating
sequence of movies and performers that lead back to Kevin Bacon. Remarkably, PathFinder.java
is precisely the program that you need to find a shortest path that establishes the Bacon number
of any performer in movies.txt.
The six degrees of separation rule suggests that most actors will have a Kevin Bacon number of
6 or less. In fact, most have a Kevin Bacon number of 3 or less!
Source:
http://introcs.cs.princeton.edu/java/45graph/
102
References
A Practical Introduction to Data Structures and Algorithm Analysis Third Edition (C++
Version)
This book provides a thorough and comprehensive treatment of fundamental data structures and
the principles of algorithm analysis. Focuses on the principles required to select or design the
data structure that will best solve the problem.
Algorithmic Problem Solving
An introduction to problem-solving and algorithm formulation using an example-driven
approach. It demonstrates the importance of mathematical calculation, but the chosen examples
are typically not mathematical.
Algorithms
Contains carefully selected and clustered algorithm topics. No attempt was made to be
encyclopedic, so that this book can include topics traditionally de-emphasized or omitted from
most Algorithms books.
Algorithms for Programmers
Selected algorithms for programmers who are interested in the treated algorithms and actually
want to create a working and reasonably optimized code.
Algorithms in the Real World: Lecture Notes
This document looks both at algorithms and at case studies in which the problems are used in
real-world applications.
Art Gallery Theorems and Algorithms
Art gallery theorems and algorithms are so called because they relate to problems involving the
visibility of geometrical shapes and their internal surfaces. This book explores generalizations
and specializations in these areas.
Art of Programming Contest
A textbook for an algorithm course focusing on programming as well as a programming course
focusing on algorithms. The book is designed to train students to participate in competitions,
especially the ACM International Collegiate Programming Contest.
Average Case Analysis of Algorithms on Sequences
Describes methods employed in average case analysis of algorithms, combining both analytical
and probabilistic tools.
104
Glossary
Acyclic, of a graph, 'having no cycles';
Adjacent, as in vertices of a graph, w is adjacent to v if there is an edge <v,w>;
Assertion, a true statement about, or a condition of, the state of a program's variables at a certain
point in the program.
Arc of a graph, direct connection between two vertices
Atom, indivisible value especially when the element of a list.
AVL tree, height balanced binary tree.
B-tree of order k (not a binary tree!) each internal node can hold k-1 keys and (pointers to) k
subtrees; ordered left to right; is height-balanced.
Binary recursion, where an activation of a subprogram may call the subprogram twice.
Binary search, to search by successive division into two equal parts.
Binary search tree, elements in left subtree < root < elements in right subtree & all subtrees also
satisfy this condition.
Binary tree, a tree where each node has 0, 1 or 2 child nodes (subtrees); also see strict binary
tree.
Breadth first traversal of a tree, visit parent then children then grand children etc.
Complete binary tree, a full binary tree where all leaf nodes are at level 'n' or 'n-1', and all
gaps, if any, are in level n at the right
Complete undirected graph, one having an edge between each pair of vertices (so it is a
clique).
Cycle, a path (see path) in a graph where the 1st and last vertices in the path are the same.
DAG, directed acyclic graph, i.e., no cycles.
106
Space complexity, amount of space an algorithm uses, and in particular how this varies with the
size, or some other property, of the data.
Spanning tree of a graph G, a subgraph which is a tree, contains all vertices of G; edges form a
subset of the edges of G.
Traverse, to visit each element, cell or node of a list, tree, graph or other data structure.
Tree (binary, rooted), either empty or contains two subtrees and usually also an element.
Tree (unrooted), a connected undirected graph where for any two vertices u and v, there is a
unique path from u to v.
Undirected graph, one where the edges, e.g., (v1,v2), have no sense of direction, (v1,v2) is
equivalent to (v2,v1).
Vertex, a point in a tree or graph.
Weighted graph, one where each edge has a cost or weight, i.e., edge-weighted; less
commonly, can also have a vertex-weighted graph.
108
1.
2.
3.
4.
5.
(a)
(a)
6.
7.
110
M.Sc.(Information Technology)
(FIRST SEMESTER)EXAMINATION, 2011
(New Scheme)
ALGORITHMIC AND APPLICATION
PAPER: T-101
TIME ALLOWED: THREE HOURS
Maximum Marks80
Note:(1) No supplementary answer-book will be given to any candidate. Hence the
candidates should write the answers precisely in the Main answer-book only.
(2) All the parts of question should be answered at one place in the answer-book.
One complete question should not be answered at different places in the answer
book.
1.(a)
(b)
2. (a)
(b)
3. (a)
(b)
4. (a)
(b)
5. (a)
6. (a)
(b)
7. (a)
..
112
References
http://www.algosort.com/
http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=...
@ http://www.topcoder.com/
http://algolist.manual.ru/
http://www.eternallyconfuzzled.com/jsw_home.aspx
@ http://www.eternallyconfuzzled.com/
http://www.topcoder.com/tc?d1=tutorials&d2=alg_index&modu...
@ http://www.topcoder.com/
http://www.risc.jku.at/people/ckoutsch/stuff/e_algorithms.html
@ http://www.risc.jku.at/
http://en.wikipedia.org/wiki/List_of_algorithms
@ http://en.wikipedia.org/
http://www.filepie.us/?title=List_of_algorithms
@ http://www.filepie.us/
http://www.scriptol.com/programming/list-algorithms.php
@ http://www.scriptol.com/
http://www.sorting-algorithms.com/
Bibliography
Data Structures and Algorithms: A First Course published by Springer Verlag, 1996. ISBN:
3540760474.
Data Structures and Algorithms published by Addison Wesley, 1983. ISBN: 0201000237. Pascal
The Design and Analysis of Computer Algorithms published by Addison Wesley, 1974. ISBN:
0201000296.
Algorithms and Data Structures published by Wordware Publishing, 2001. ISBN: 1556227361.
Delphi
Introduction to Algorithms 2nd edition, published by M.I.T. Press/Triliteral, 2001. ISBN:
0262032937. General
Data Structures and Algorithms in C++ 2nd edition, published by Brooks/Cole Pub Co, 2000.
ISBN:
Practical Data Structures in C++ published by John Wiley & Sons, 1993. ISBN: 047155863X.
C++
Data Structures with C++ Using STL 2nd edition, published by Prentice Hall, 2001. ISBN:
0130858501. C++
Data Structures: A Pseudocode Approach with C++ published by Brooks/Cole Pub Co, 2000.
ISBN: 053495216X. C++
Data Structures and Algorithms in Java 2nd edition, published by John Wiley & Sons, 2000.
ISBN: 0471383678. Java
Object-Oriented C++ Data Structures for Real Programmers published by Morgan Kaufmann
Data Abstraction & Structures Using C++ published by Jones & Bartlett Pub, 1996. ISBN:
0763702951. C++
114