LECTURE NOTES FOR COMPUTER SCIENCE STUDENTS
E-Commerce New
PROGRAMS
C++ PROGRAMS
JAVA PROGRAMS
Computer Graphics PROGRAMS
Data Structures PROGRAMS
Data Structures using C++ Programs
Operating System Programs
General Knowledge
Aptitude
LECTURE NOTES FOR COMPUTER SCIENCE STUDENTS
E-Commerce New
PROGRAMS
C++ PROGRAMS
JAVA PROGRAMS
Computer Graphics PROGRAMS
Data Structures PROGRAMS
Data Structures using C++ Programs
Operating System Programs
General Knowledge
Aptitude
DATA STRUCTURES
1.What is an Algorithm?
An algorithm is clearly specified set of simple instructions to be followed to solve a problem. The algorithm forms a base for program.
2.What are the properties of an Algorithm?
_ Takes zero or more inputs
_ Results in one or more outputs
_ All operations are carried out in a finite time
_ Efficient and flexible
_ Should be concise and compact to facilitate verification of their
correctness.
3.Define Program?
It is an instruction and it is written according to the instructions, which is given in the algorithm.
4. What is Complexity analysis?
It is the analysis of the amount of memory and time an algorithm requires to completion.
There are two types of Complexity
1. Space Complexity
2. Time Complexity
5. Explain the performance analysis of the algorithm?
The analysis of the performance of an algorithm based on specification is called performance analysis. It is loosely divided into
a. Priori estimates
b. Posterior Testing
6. Explain Space complexity?
Space complexity of an algorithm is the amount of memory it needs to run to completion.
7. Explain Time complexity?
Time complexity is the amount of computer time an algorithm requires to run to completion.
8. List out the components that are used for space complexity?
a. Instruction Space
b. Environment Stack
c. Data Space.
9. What do asymptotic notation means?
Asymptotic notations are terminology that is introduced to enable us to make meaningful statements about the time and space complexity of an algorithm.
The different notations are
Big – Oh notation
Omega notation
Theta notation.
10. Define Efficiency of an algorithm?
It denotes the rate at which an algorithm solves a problem of size n. It is measured by the amount of resources it uses, the time and the space.
DATA STRUCTURES
11. Define Worst case of an algorithm?
It is the longest time that an algorithm will use over all instances of size n for a
given problem to produce the result.
12. Define Best case of an algorithm?
It is the shortest time that an algorithm will use over all instances of size n for
a given problem to produce the result.
13. Define average case an algorithm?
It is the average time that an algorithm will use over all instances of size n for
a given problem to produce the result.
14. Define Divide and Conquer algorithm?
Divide and Conquer algorithm is based on dividing the problem to be solved
into several, smaller sub instances, solving them independently and then combining
the sub instances solutions so as to yield a solution for the original instance.
15. Mention some application of Divide and Conquer algorithm?
a. Quick Sort
b. Merge Sort
c. Binary search
16. Define dynamic programming algorithm?
Dynamic programming algorithm is a general class of algorithms which solve
problems by solving smaller versions of the problem, saving the solutions to the
small problems and then combining them to solve the larger problems.
17. Mention application of dynamic programming algorithm?
Efficient Fibonocci number computation
Chained matrix multiplication.
Longest common subsequence problem
18. State the various steps in algorithm?
Devising the algorithm
Validating the algorithm
Expressing the algorithm
Determination of complexity of the algorithm
19. Define algorithm paradigms space of an algorithm?
Algorithmic paradigms are defined as the general approach to design and construct efficient solutions to problems.
20. Mention the various spaces utilized by a program?
a. A fixed amount of memory occupied by the space for the program code and space occupied by the variables used in the program.
b. A variable amount of memory occupied by the variable whose size is dependent on the problem being solved. This space increases or decreases depending upon whether the program uses iterative or recursive procedures.
DATA STRUCTURES
31 Define HEAD pointer and NULL pointer?
HEAD It contains the address of the first node in that list. NULL It indicates the end of the list structure.
32 What is meant by dummy header?
It is ahead node in the linked list before the actual data nodes.
33 Define Circular linked list?
It is a list structure in which last node points to the first node there is no null value.
34 Write operations that can be done on stack?
PUSH and POP
35 Mention applications of stack?
a. Expression Parsing
b. Evaluation of Postfix
c. Balancing parenthesis
d. Tower of Hanoi
e. Reversing a string
36 Define Infix, prefix and postfix notations?
Infix operators are placed in between the operands
Prefix operators are placed before the operands
Postfix Operators are placed after the operands.
40. a) Define double linked list? It is linear data structure which consists of two links or pointer fieldsNext pointer points to the address of the next(successor) node.Previous pointer points to the address of the previous(predecessor) node.
37 What are the conditions that followed in the array implementation of queue?
Condition Situation
REAR
38 What are the conditions that could be followed in a linked list implementations of
queue?
Condition Situation
REAR==HEAD EMPTY QUEUE
REAR==LINK(HEAD) ONE ENTRY QUEUE
NO FREE SPACE TO INSERT FULL QUEUE
39 What are the conditions that could be followed in a linked list implementations of
queue?
Condition Situation
(REAR MOD ARRAY SIZE +1
)==FRONT
EMPTY QUEUE
(REAR MOD ARRAY SIZE +2
)==FRONT
FULL QUEUE
FRONT==REAR ONE ENTRY QUEUE
40 Define Circular queue?
A circular queue allows the queue to wrap around upon reaching the end of the array.
DATA STRUCTURES
51.Construction of expression trees?
1.convert the given infix expression into postfix notation
2. Create a stack and read each character of the expression and push into the stack, if operands are encountered.
3.when an operator is encountered pop 2 values from the stack. From a tree using the operator.
52.Define lazy deletion?
When an element is to be deleted it is left in the tree itself and marked a s being deleted. This is called as lazy deletion and is an efficient procedure if duplicate keys are present in the binary search tree, because the field
that keeps count of the frequency of appearance of the element can be decremented of the element can be decremented.
53.Define AVL tree?
AVL tree also called as height balanced tree .It is a height balanced tree in which every node will have a balancing factor of –1,0,1 Balancing factor Balancing factor of a node is given by the difference between the
height of the left sub tree and the height of the right sub tree.
54.what are the various operation performed in the binary search tree ?
1.insertion
2.deletion
3.find
4.find min
5.find max
55. What are the various transformation performed in AVL tree?
1.single rotation
- single L rotation
- single R rotation
2.double rotation
-LR rotation
-RL rotation
56.General idea of hashing and what is the use of hashing function?
A hash table similar to an array of some fixes size-containing keys. The keys specified here might be either integer or strings, the size of the table is taken as table size or the keys are mapped on to some number on the hash table from a range of 0 to table size
57.what is priority queue?
A priority queue is a data structure that allows at least the following two operations: insert which does the obvious thing; and Deletemin, which finds, returns, and removes the minimum element in the priority queue. The Insert operation is the equivalent of Enqueue.
58.Applecation of priority queues?
1.for scheduling purpose in operating system
2.used for external sorting
3.important for the implementation of greedy algorithm, which operate by repeatedly finding a minimum.
59.what are the main properties of a binary heap?
1.structure property
2.heaporder property
60. Define tree traversal and mention the type of traversals?
Visiting of each and every node in the tree exactly is called as tree
traversal
Three types of tree traversal
1.inorder traversal
2.preoder traversal
3.postorder traversal.
DATA STRUCTURES
61. what is insertion sort? How many passes are required for the elements to be sorted ?
one of the simplest sorting algorithms is the insertion sort. Insertion sort consist of N-1 passes . For pass P=1 through N-1 , insertion sort ensures that the elements in positions 0 through P-1 are in sorted order .It makes use of the fact that elements in position 0 through P-1 are already known to be in sorted order .
62. Write the function in C for insertion sort ?
void
insertionsort(elementtype A[ ] , int N)
{
int j, p;
elementtype tmp;
for(p=1 ; p
a [ j ]=a [j-1 ] ;
a [ j ] = tmp ;
}
}
63. Who invented shellsort ? define it ?
Shellsort was invented by Donald Shell . It works by comparing element that are distant . The distance between the comparisons decreases as the algorithm runs until the last phase in which adjacent elements are compared . Hence it is referred as diminishing increment sort.
64. write the function in c for shellsort?
Void
Shellsort(Elementtype A[ ],int N)
{
int i , j , increment ;
elementtype tmp ;
for(elementtype=N / 2;increment > 0;increment / = 2)
For( i= increment ; i
if(tmp<>
65. what is maxheap?
If we want the elements in the more typical increasing sorted order,we can change the ordering property so that the parent has a larger key than the child.it is called max heap.
66. What are the two stages for heap sort?
Stage 1 : Construction of heap
Stage 2 : Root deletion N-1 times
67. What is divide and conquer strategy ?
In divide and conquer strategy the given problem is divided into smaller Problems and solved recursively. The conquering phase consists of patching together the answers . Divide – and – conquer is a very powerful use of recursion that we will see many times.
68 . Differentiate between merge sort and quick sort ?
mergesort quicksort
1. Divide and conquer stategy Divide and conquer strategy
2. Partition by position Partition by value
69.Mention some methods for choosing the pivot element in quicksort ?
1. choosing first element
2. Generate random number
3. Median of three
70. What are the three cases that arise during the left to right scan in quicksort?
1. I and j cross each other
2. I and j do not cross each other
3. I and j points the same position
80. Give some example of NP complete problems.
i. Hamiltonian circuit.
ii. Travelling salesmen problems
iii. Longest path problems
iv. Bin packing
v. Knapsack problem
vi. Graph colouring problem
DATA STRUCTURES
81. What is a graph?
A graph consists of a set of vertices V and set of edges E which is
mathematically represented as G=(V,E).Each edge in a pair(V,W) where V,W,
belongs to E ,edges are sometimes referred to as arcs.
82. What are Directed graphs?
If a pair of vertices for any edge is ordered, then that graph is called as
Digraph or directed graph.
83. Define Path.
A path in a graph is a sequence of vertices w1,w2w,3,wN such that Wi,Wi+1 belongs to E for a value 1<=I<=N. The length of such a path is the number Edges on the path,which is equal to n-1.
84. Define Cycle.
A cycle is a path in which the first and last vertices are the same.
85. Define Acyclic graph.
A graph with no cycles is called Acyclic graph.A directed graph with no Edges is called as a directed Acyclic graph (or) DAG.DAGS are used for compiler Optimization process.
86. Define Connected graph.
An undirected graph is connected if there is a path from every vertex to Every other vertex.A directed graph with this property is called as strongly connected Connected graph.If a directed graph is not strongly connected but the underline graph Without direction is connected it is called as a weakly connected graph.
87. What are the conditions for a graph to become a tree?
A graph is a tree if it has two properties.
i. If it is a connected graph.
ii. There should not be any cycles in the graph.
88. Define a Weighted Graph.
A graph is said to be a weighted graph if every edge in the graph is
Assigned some weight or value.The weight of the edge is a positive value that
Represents the cost of moving the edge or the distance between two vertices.
89. Give the types of representation of graphs.
1.Adjacency matrix
2.Adjacency linked list
90. What is a minimum spanning tree?
A minimum spanning tree of an undirected graph G is a tree formed
from Graph edges.that connect all the vertices of G at lowest total cost.
DATA STRUCTURES
Previous Next
91. Explain about Adjacency Matrix
Adjacency matrix consists of a n*n matrix where n is the no. of vertices
present In the graph,which consists of values either 0 or 1.
92. Explain about Adjacency linked list.
It consists of a table with the no. of entries for each vertex for each entry a
linked List is inititated for the vertices adjacent to the corresponding table entry.
93. What is a single souce shortest path problem?
Given as an input,a weighted graph,G=
as the source vertex.Single source shortest path problem finds the shortest
weighted path from s to every other vertex in G.
94. Explain about Unweighted shortest path.
Single source shortest path finds the shortest path from the source to each
and every vertex present in a unweighted graph.Here no cost is associated
with the edges connecting the vertices.Always unit cost is associated with
each edge.
95. Explain about Weighted shortest path
Single source shortest path finds the shortest path from the source to each
and
Every vertex present In a weighted graph.In a weighted graph some cost is
always
Associated with the edges connecting the vertices.
96. What are the methods to solve minimum spanning tree?
a) Prim’s algorithm
b) Kruskal’s algorithm
97. Explain briefly about Prim’s algorithm
Prim’s algorithm creates the spanning tree in various stages.At each stage,a
node is picked as the root and an edge is added and thus the associated
vertex along with it.
98. Define a depth first spanning tree.
The tree that is formulated by depth first search on a graph is called as depth
first spanning tree.The depth first spanning tree consists of tree edges and
back edges.
99. What is a tree edge?
Traversal from one vertex to the next vertex in a graph is called as a tree
edge.
100. What is a back edge?
The possibility of reaching an already marked vertex is indicated by a dashed
line,in a graph is called as back edge.
1.What are the various operations on stack?Explain.
2.Write the functions to perform the following operations on a singly linked list.
i. Adding node at between any two nodes
ii. Deleting a node from any where.
iii. Adding node at beginning and end
iv. Deleting a first and last node.
3.i)Explain about any two applications of stack in detail with suitable example.
ii)Write the functions to perform the insert and delete operations on queue.
4.i)Give two sorted lists L1 and L2.Write a procedure to compute L1U L2 using the basic list operations.
ii)Write a program to print out the elements of a singly linked list.
5.i)Write an algorithm /program to convert infix expression to post fix expression using stack.
ii)What is meant by priority queue?
6.Explain in detail Queue data structure.
7.Explain in detail Linear Linked List.
8.Explain in detail Circularly linked list.
9.i)List the advantages of circular queue ?
ii)How to represent the queue using array?
DATA STRUCTURES
PART - A Questions
1. Define “Data Structures”.
2.Differentiate linear and nonlinear data structure?
3.What is an Array?What are row major order and column major ordering in an array?
4.Differentiate between static and dynamic data structures?
5.Define stack and various operations performed in it?
6.What is stack overflow and underflow?
7.Explain the array representation of stack?
8.What are the basic properties of Arrays?
9.Define a queue?
10.Mention any two similarities and dissimilarities between stack and queues.
11.What is Deque?
12.What is a priority queue?
13.Discuss “Circular queues” with an example.
14.Define Lists?
15.what is Linked list? List out the different types of linked lists bringing out the differences between each.
16.What are the applications of stack?
17.What are the applications of queue?
18.What are the advantages of using Doubley linked list over singly linked list?
19.Write an algorithm to count the number of nodes in a singly linked list?
20.List the disadvantages of array?
21. What are trees?
22. What is a binary tree and list out the its properties?
23. How are Binary trees represented ?
24. Define a Binary Search Tree.
25. Write algorithm for post order traversal of a Binary tree?
26. Represent the following algebraic expression into binary tree form:
A + (B-C)*(E+F)/G.
27. How to represent a binary tree in memory using an array? Mention the disadvantages of using an array to represent a binary tree.
28. What is meant by sorting?
29. How do you compute the time complexity for sorting algorithm?
30. What is meant by Internal Sorting?
31. Sort the following numbers using Merge sort 15,5,30,6,3,95.
32. What is the time complexity of Tree sorting and Merge sorting?
33. How to represent a binary tree in memory using an array?Mention the disadvantages of using an array to represent a binary tree.
34. Sort the following numbers using Radix sort:
17,220,8,45,1875.
35. What are the major differences between linear search and binary search procedures? Write their time complexity.
36. What do you mean by Hash function? Give an example.
1. Explain about any two applications of stack in detail with suitable example.
2. i)Give two sorted lists L1 and L2.Write a procedure to compute L1U L2 using the basic list operations.
ii)Write a program to print out the elements of a singly linked list.
3. i) Discuss the various representations of a binary tree in memory with suitable example.
ii).What are the basic operations can be performed on a binary tree? Explain each of them in detail with suitable example.
4). i) Write the in-order, pre-order and post order traversal of a given Tree.
ii)Write a recursive algorithm to find the post order traversal of a tree.
iii)Write briefly about Huffman Algorithm.
5. i)Write the algorithm for insertion sort and demonstrate with an example.
ii)Sort the following nos.:43,32,16,7,-10,120,45,2,54,71,96 using Radix sort.
6. Explain the Quick sort algorithm. Using this algorithm sort the following numbers: 15,97,13,28,101,188,5,3,1,56,54
PART - B
7. Write the functions to perform the following operations on a singly linked list.
i. Adding node at between any two nodes
ii. Deleting a node from any where.
iii. Adding node at beginning and end
iv. Deleting a first and last node.
8. Explain in detail Circularly linked list.
9. i)Discuss the various representations of a binary tree in memory with
suitable example.
ii)Write briefly about Huffman Algorithm.
10. What is binary search tree? Explain it with suitable example. Write an
algorithm to search an element in the binary search tree.
11. i) Differenciate between Heap sort and Radix sort.
ii) Explain insertion sort algorithm .
12. i) Explain Heap Sort with example.
ii)Explain Merge sort algorithm .Using this algorithm sort the following numbers:
33,66,22,56,77,44,99,32,58.
13. i) Write the functions to perform the insert and delete operations on queue.
ii) What are the various operations on stack? Explain.
14. i) Write an algorithm /program to convert infix expression to post fix expression using stack.
ii)List the advantages of circular queue ?
15. Explain binary tree traversal with suitable example.
b)Explain binary search tree.How to insert a node into the binary tree?
16. i) What are the advantages and disadvantages of various basic searching methods?
ii) Explain insertion sort algorithm .
17. i) Explain bubblesort algorithm.
ii)Explain merge-sort algorithm with example.
Internet and other novelties
The Internet functions as a medium for data transmission in much the same way that the international telephone network functions as a medium for voice and other signal transmission. The telephone system consists of connections and the required supporting hardware and cabling to people, organizations and devices answering and fax machines, computers and others but does not include those things nor does it include the signals being sent over it.
The Internet can be said to consist of the connections and the required supporting hardware and cabling between network and not the data stored on and made accessible from those network. The Internet Advisory Board (IAB) provides oversight to the Internet Engineering Task Force, which is responsible for evaluating and defining Internet protocols. The Internet protocols are also known as TCP/IP the 2 most central protocols defining inter network transmissions. If you are using a computer connected to a network that conforms to the Internet protocols and is connected to global Internet, we can exchange data with any other computer connected to global Internet as long as that computer also conforms to Internet protocols.
Networks and Electronic transactions today- With wide spread use of credit cards, consumers and merchants have been happily transacting business over telephone network for many years. Once participants in electronic market understand the mechanisms set up for transacting business across the Internet, buying and selling online will be at least as simple and trusted a method as buying by phone or in person.
WWW standards
The World Wide Web is defined by a handful of protocol specifications. Software developers use those specifications to implement the web browser and web server programs. The interaction between browser and server is by Hypertext Transfer Protocol (HTTP). Web browsers send messages conforming to this protocol to web server, this in turn return requested information.
The Uniform Resource Locator (URL) protocol specifies how individual resources are to be identified within the WWW. Web browsers use these URLs in HTTP requests to remote servers. They identify to the server exactly what resource is being requested.
Hypertext markup language (HTML) tags which define the different functional pieces of each document. HTML documents consist of plain text (ASCII) files and may point to graphics files, other types of multimedia files like audio or video files stored in standard formats or other network resources (URLs).
The Common Gateway Interface (CGI) specifies mechanisms for passing information from the person browsing your web server to other resources available through that server, in particular by collecting information from remote user in web forms and then passing that information along to the other resource. CGI provides the link between the web server and the rest of the commercial process. The security protocols relevant to WWW include Secure Sockets Layer (SSL) and Secure Hypertext Transfer Protocol(S-HTTP). They add security to existing protocols between the browsers and servers that support them.
Browsers and Servers-
Web browsers or clients must be able to send HTTP requests and receive HTTP replies from servers. Browser functions can also be integrated into more complete network or communications packages or even into operating systems like IBM’s OS/2 Warp.
Web servers are set up on higher performance systems with higher performance connections to the internet.
Required facilities
The merchant must understand that purchasing products over Internet requires a significant investment in software, hardware and services. The majority of Internet merchants will be unlikely to set up their own secure servers, because doing so can be complicated for the Internet novice, and also because there are so many companies now offering such services. However, merchants who are aware of what their options are can be smarter consumers of these services, and customers who are aware of how their online orders are processed can be smarter online consumers.
Hardware
Any computer that can run an implementation of TCP/IP and that can be connected to Internet can be a www server. The system should have more processing power, should have sufficient hard disk to store all information fast, Internet connection to support maximum expected load, security features to protect system from unauthorized access.
Some organizations using Internet may prefer to simply get a server and an Internet connection and leave their internal networks out of the loop. Some kind of firewalls is necessary to protect their network from intruders.
Software
TCP/IP implementation is necessary for web server. This may be built in to the operating system, or it may be a part of web server package. System administrators make sure that there is no other software on Internet servers. This guarantees that if an intruder should compromise that system, no network is available to intruder for further mischief. This is the software that responds to requests from browsers on the Internet and sends out the desired information. Security should be a part of the operating system.
Electronic malls
Setting up a web site for buying and selling can be complicated and expensive, it is not for everyone. However some companies have been setting up electronic or vital or online malls. The shopping mall is a familiar and comfortable model for consumers and merchants and it is relatively straightforward to simulate using the World Wide Web. Mall operators allow individual merchants to rent space on the mall. The financial arrangements may vary but include some monthly charge, charge for storage space required and charge for each transaction. As part of the ability to sell products electronically, the online commercial environment should provide at least some of the following abilities:
· Automatically process responses from the credit card authentication service.
· Get digital signatures or other proof of approval of the order from the customer
· Generate necessary transaction tracking information, including electronic receipts, customer statements and internal documentation of orders.
· For non electronic material. Have a link to the delivery company for delivery status between the vendor and the customer.
· Be able to handle occasional telephone or fax transactions as well as online transactions.