0% found this document useful (0 votes)
10 views

1.Course File Index - Theory

The document outlines the course file for the C Programming and Data Structures course at Anand Institute of Higher Technology, detailing the course objectives, syllabus, and various assessments. It includes a faculty timetable, a list of students, and a comprehensive breakdown of topics covered in the course. The document also provides information on course outcomes and references for further reading.

Uploaded by

vimalrajas.csbs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

1.Course File Index - Theory

The document outlines the course file for the C Programming and Data Structures course at Anand Institute of Higher Technology, detailing the course objectives, syllabus, and various assessments. It includes a faculty timetable, a list of students, and a comprehensive breakdown of topics covered in the course. The document also provides information on course outcomes and references for further reading.

Uploaded by

vimalrajas.csbs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

ANAND INSTITUTE OF HIGHER TECHNOLOGY

Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai


An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
COURSE FILE – THEORY
INDEX
Sl. No. CONTENT
1. Mission and Vision of the Institute and Department
2. Faculty Timetable
3. Student Name List
4. Syllabus
5. Lesson Plan
6. Two Mark questions with Answer & 16 Mark Questions
7. University Question Paper
8. Monthly Test-I Question Paper
9. Mark Statement for Monthly Test-I
10. Result Analysis Report for Monthly Test-I
11. Sample Answer Scripts
12. Monthly Test-II Question Paper
13. Mark Statement for Monthly Test-II
14. Result Analysis Report for Monthly Test-II
15. Sample Answer Scripts
16. Model Exam Question Paper
17. Mark Statement for Model Exam
18. Result Analysis Report for Model Exam
19. Sample Answer Scripts
20. AssignmentQuestions
21. Sample Assignments
22. University Examination Result Analysis
23. Class Notes
24. Log Book
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

Faculty Timetable

1 2 3 4 5 6 7 8
Period 10.45 to 12:30 –
& 11.00 1:05
8:30 –
Day 9:15 – 10:00 – A.M 11:00 – 11:45 – P.M 1:05 – 1:50 – 2:35 2:35 – 3:20
9:15
10:00 A.M 10:45 A.M 11:45 A.M 12.30 P.M 1:50 P.M P.M P.M
A.M

MON

TUE CS3353
B L
R U
WED E N CS3353
A C
K H
THU CS3353 CS3353

FRI CS3353

CS3353 – C Programming and Data Structures


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

Student Name List


ANAND INSTITUTE OF HIGHER TECHNOLOGY
S.No. Register No. Name of the Student
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
1 310123106001 ANNAMALAI.K
An ISO 9001:2008 Certified Institution & Accredited by NBA
2 310123106002 ANTO.J
3 310123106003 DEPARTMENT
ANUSHYA EVANGELIN.EOF ECE
4 310123106004 BABIN JOE.R
5 310123106005 BEULA.R
6 310123106006 DEVI SRI.R
7 310123106007 DHARSHINI.K
8 310123106008 GABRIEL.J
9 310123106009 GOWTHAM.K
10 310123106010 HARIHARAN.K
11 310123106011 HARIHARAN.K
12 310123106012 JANAVI.
13 310123106013 JAYANTHI.V
14 310123106014 KANAGASUNDARI.D
15 310123106015 KEERTHI VASAN.M
16 310123106016 KISHOR KUMAR.S
17 310123106017 LAVANYA.R
18 310123106018 LAVANYA.V
19 310123106019 LOGAPRIYA.T
20 310123106020 MADHESH.K
21 310123106021 MANOJ.R
22 310123106022 MOHITHA.S.R
23 310123106023 MONISHA.K
24 310123106024 MUTHU ARUNACHALAM.D
25 310123106025 PADMAJAA.E
26 310123106026 POONGODI.E
27 310123106027 PRATHAP.L
28 310123106028 PRITHIV RAJ.V
29 310123106029 PRIYADHARSHINI.P
30 310123106030 PRIYADARSHINI.R
31 310123106031 RAGUL.N
32 310123106032 RAGUNATH.M
S.No. Register No. Name of the Student
33 310123106033 RAJARAJAN.S.V
34 310123106034 ROSHAN.M
35 310123106035 SANDHIYA SRI.R
36 310123106036 SURYAPRIYA.C
37 310123106037 VETRIVEL.R
38 310123106038 VIJAYALAKSHMI.B
39 310123106039 VIMAL.S
40 310123106040 VISHNU.S
41 310123106041 YUKESH.M
42 310123106042 YUVASHREE.R
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
CS3353 C PROGRAMMING AND DATA STRUCTURES LT PC
3003
COURSE OBJECTIVES:
 To introduce the basics of C programming language.
 To learn the concepts of advanced features of C.
 To understand the concepts of ADTs and linear data structures.
 To know the concepts of non-linear data structure and hashing.
 To familiarize the concepts of sorting and searching techniques.

UNIT I C PROGRAMMING FUNDAMENTALS (8+1 SKILL) 9


Data Types – Variables – Operations – Expressions and Statements – Conditional Statements
Functions – Recursive Functions – Arrays – Single and Multi-Dimensional Arrays.

UNIT II C PROGRAMMING - ADVANCED FEATURES (8+1 SKILL) 9


Structures – Union – Enumerated Data Types – Pointers: Pointers to Variables, Arrays and
Functions – File Handling – Preprocessor Directives.

UNIT III LINEAR DATA STRUCTURES (8+1 SKILL) 9


Abstract Data Types (ADTs) – List ADT – Array-Based Implementation – Linked List –
Doubly- Linked Lists – Circular Linked List – Stack ADT – Implementation of Stack –
Applications – Queue ADT – Priority Queues – Queue Implementation – Applications.

UNIT IV NON-LINEAR DATA STRUCTURES (8+1 SKILL) 9


Trees – Binary Trees – Tree Traversals – Expression Trees – Binary Search Tree – Hashing -
Hash Functions – Separate Chaining – Open Addressing – Linear Probing– Quadratic Probing
– Double Hashing – Rehashing.

UNIT V SORTING AND SEARCHING TECHNIQUES (8+1 SKILL) 9


Insertion Sort – Quick Sort – Heap Sort – Merge Sort –Linear Search – Binary Search.
TOTAL: 45 PERIODS
SKILL DEVELOPMENT ACTIVITIES (Group Seminar/Mini Project/ Assignment/
Content Preparation / Quiz/ Surprise Test / Solving GATE questions/ etc) 5
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
COURSE OUTCOMES:
CO1:Develop C programs for any real world/technical application.
CO2:Apply advanced features of C in solving problems.
CO3:Write functions to implement linear and non–linear data structure operations.
CO4:Suggest and use appropriate linear/non–linear data structure operations for solving a
given problem.
CO5:Appropriately use sort and search algorithms for a given application.
CO6:Apply appropriate hash functions that result in a collision free scenario for data storage
and retrieval.

TEXT BOOKS:
1. Mark Allen Weiss, “Data Structures and Algorithm Analysis in C”, Second Edition, Pearson
Education, 1997.
2. ReemaThareja, “Programming in C”, Second Edition, Oxford University Press, 2016.

REFERENCES:
1. Brian W. Kernighan, Rob Pike, “The Practice of Programming”, Pearson Education, 1999.
2. Paul J. Deitel, Harvey Deitel, “C How to Program”, Seventh Edition, Pearson Education,
2013.
3. Alfred V. Aho, John E. Hopcroft, Jeffrey D. Ullman, “Data Structures and Algorithms”,
Pearson Education,1983.
4. Ellis Horowitz, SartajSahni and Susan Anderson, “Fundamentals of Data Structures”,
Galgotia, 2008.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
CS3353 C Programming and Data Structures

UNIT- I
1. List the different data types available in C?
Floating-point, integer, double, character. Union, structure, array, etc. The
basic data types are also known as the primary data types in C programming.
2. What do you mean by variables in ‘C’?
Variables are containers for storing data values. In C, there are different
types of variables (defined with different keywords), for example: int - stores
integers (whole numbers), without decimals, such as 123 or -123. float - stores
floating point numbers, with decimals, such as 19.99 or -19.99.

3. What is the use of sizeof() operator in C.


It is a compile-time operator as it returns the size of any variable or a constant
at the compilation time. The size, which is calculated by the sizeof() operator, is the
amount of RAM occupied in the computer.
Syntax of the sizeof() operator is given below: sizeof(data_type);

4. What is the difference between ++a and a++?


++a returns the value of an after it has been incremented. It is a pre-
increment operator since ++ comes before the operand. a++ returns the value of a
before incrementing. It is a post-increment operator since
++ comes after the operand.

5. What are Operators? Mention their types in C


An operator is a symbol which operates on a vari able or value. There are types
of operators like arithmetic, logical, conditional, relational, bitwise, assignment
operators etc. Some special types of operators are also present in C like sizeof(),
Pointer operator

6. What do you meant by conditional or ternary operator?


A ternary operator evaluates the test condition and executes a block of code
based on the result of the condition. Its syntax is condition ? expression1 :
expression2; Here, condition is evaluated and. if condition is true , expression1 is
executed.

7. What are the types of looping statements available in C


Loop is used to execute the block of code several times according to the
condition given in the loop. It means it executes the same code multiple times so it
saves code and also helps to traverse the elements of an array.

There are 3 types of loop –


 while loop
 do – while loop
 for loop
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

8. What is the difference between ‘=’ and ‘==’ operator?


The “=” is an assignment operator is used to assign the value on the right to the
variable on the left. The '==' operator checks whether the two given operands are equal or
not.
9. What are the types of I/O statements available in ‘C’?
Input/output statement or IO statement is a portion of a program that instructs a
computer how to read and process data. It pertains to gathering information from an
input device, or sending information to an output device.
10. Define Array
An array is a variable that can store multiple values. For example, if you want to
store 100 integers, you can create an array for it.
int data[100];
11. List down the Primary Data Types in C
• Integer – We use these for storing various whole numbers, such as 5, 8, 67, 2390, etc.
• Character – It refers to all ASCII character sets as well as the single alphabets, such as ‘x’,
‘Y’, etc.
• Double – These include all large types of numeric values that do not come under either
floating-point data type or integer data type.
• Floating-point – These refer to all the real number values or decimal points, such as 40.1,
820.673, 5.9, etc.
• Void – This term refers to no values at all. We mostly use this data type when defining the
functions in a program.

12. What is Variable?


Variables are containers for storing data values. Its value can be changed, and it can be
reused many times.
Syntax for creating variables
type variableName = value;
Example: int a = 5;

13. What is Operator?


An operator is a special symbol that tells the compiler to perform specific mathematical
or logical operations. Operators in programming languages are taken from mathematics. C
language supports a rich set of built-in operators.
14. List the types of operators supported in C
✓ Arithmetic operators
✓ Relational operators
✓ Logical operators
✓ Bitwise operators
✓ Assignment operators
✓ Type Information Operators(Special operators)

15. What is Ternary operators or Conditional operators?


Ternary operators is a conditional operator with symbols ? and :
Syntax: variable = exp1 ? exp2 : exp3
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
If the exp1 is true variable takes value of exp2. If the exp2 is false, variable takes the
value of exp3.

16. What is an Operator and Operand?


An operator is a symbol that specifies an operation to be performed on operands.
Example: *, +, -, / are called arithmetic operators.
The data items that operators act upon are called operands.

17. What is type casting?


Type casting is the process of converting the value of an expression to a particular data
type. Example: int x,y.
c = (float) x/y; where a and y are defined as integers. Then the result of x/y is converted
into float.

18. What is the difference between while loop and do while loop?
while do while
In the while loop the condition is first In the do…while loop first the
executed. statement is executed and then the
condition is checked.
If the condition is true, then it The do…while loop will execute at
executes the body of the loop. When least one time even though the
the condition is false it comes of the condition is false at the very first
loop. time.

19. What is a Function?


A function is a block of code which only runs when it is called. It performs a specific
task.

20. What is meant by Recursive function?


If a function calls itself again and again, then that function is called Recursive function.
The syntax for recursive function is:
function recurse()
{
// function code
recurse();
// function code
}
recurse();

21. Write short notes about main() function in ’C’ program.


Every C program must have main () function. All functions in C, has to end with ‘( )’
parenthesis. It is a starting point of all ‘C’ programs. The program execution starts from the
opening brace ‘{‘ and ends with closing brace ‘}’, within which executable part of the program
exists.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

22. Give the syntax for the ‘for’ loop statement


for (Initialize counter; Test condition; Increment / Decrement)
{
statements;
}
23. What is an Array?
An array is defined as finite ordered collection of homogenous data, stored in
contiguous memory locations.
➢ finite means data range must be defined.
➢ ordered means data must be stored in continuous memory addresses.
➢ homogenous means data must be of similar data type.
For example: if you want to store marks of 50 students, you can create an array for it.
int marks[50];

24. What are the different types of arrays available in C.


✓ One-dimensional arrays
✓ Multidimensional arrays

25. Write short notes on One-dimensional arrays.


A One-Dimensional Array in C programming is a special type of variable that can store
multiple values of only a single data type such as int, float, double, char etc. The syntax of
declaring Two-dimensional arrays is:
datatype array name [size] ;
For example, int a[5]

26. Write short notes on Two-dimensional arrays.


A multi-dimensional array can be termed as an array of arrays that stores homogeneous
data in tabular form. The general form of declaring Two-dimensional arrays is:
data_type array_name[x][y];
Example : int x[10][20];

27. What are the key features in the C programming language?


✓ Portability: It is a platform-independent language.
✓ Modularity: Possibility to break down large programs into small modules.
✓ Flexibility: The possibility of a programmer to control the language.
✓ Speed: C comes with support for system programming and hence it compiles and executes
with high speed when compared with other high-level languages.
✓ Extensibility: Possibility to add new features by the programmer.

28. What is a nested loop?


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
A loop that runs within another loop is referred to as a nested loop. The first loop is
called the Outer Loop and the inside loop is called the Inner Loop. The inner loop executes
the number of times defined in an outer loop.

29. What are the modifiers available in C programming language?


✓ Short
✓ Long
✓ Signed
✓ Unsigned
✓ long long

30. What is the explanation for prototype function in C?


Prototype function is a declaration of a function with the following information to the
compiler.
• Name of the function.
• The return type of the function.
• Parameters list of the function.
✓ Example
• int sum(int,int);

31. What do you mean by the Scope of the variable?


Scope of the variable can be defined as the part of the code area where the variables
declared in the program can be accessed directly. In C, all identifiers are lexically (or
statically) scoped.

32. Can a C program be compiled or executed in the absence of a main()?


The program will be compiled but will not be executed. To execute any C program,
main() is required.

33. What is the main difference between the Compiler and the Interpreter?
Interpreter Compiler
Translates program one statement at a Scans the entire program and translates it as a
time. whole into machine code.
Interpreters usually take less amount of Compilers usually take a large amount of time to
time to analyze the source code. analyze the source code. However, the overall
However, the overall execution time is execution time is comparatively faster than
comparatively slower than compilers. interpreters.
No Object Code is generated, hence are Generates Object Code which further requires
memory efficient. linking, hence requires more memory.
Programming languages like JavaScript, Programming languages like C, C++, Java use
Python, Ruby use interpreters. compilers.

PART-B
1. Explain the different types of operators with neat examples.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
2. Illustrate the different conditional statements available in C with syntax and examples
3. Explain the looping statements with neat examples.
4. What is an Array? Explain Single and Multi-Dimensional arrays with neat examples.
5. Write a C program for Matrix Multiplication with a 3*3 matrix.
6. Create a C program for Matrix Addition.
7. Write a C program to calculate the total, average and grade for 50 Students.
8. Write a C program to calculate the factorial of a given number.
9. Write a C program to check whether a given number is odd or even.
10. Write a C program to check whether a given number is prime or not.
11. Write a C program to check whether a given number is a palindrome or not.
12. Write a C program to check whether a given number is a Armstrong number or not.

UNIT -II
1. What is a pointer? give examples
A pointer is a variable that stores the address of another variable. Example, an integer variable holds (or
you can say stores) an integer value, however an integer pointer holds the address of a integer variable.
2. List the advantages of using pointers
(i) Pointers make the programs simple and reduce their length.
(ii) Pointers are helpful in allocation and de-allocation of memory during the execution of the
program. Thus, pointers are the instruments of dynamic memory management.
(iii) Pointers enhance the execution speed of a program.
(iv) Pointers are helpful in traversing through arrays and character strings. The strings are also
arrays of characters terminated by the null character (‘\O’).
(v) Storage of strings through pointers saves memory space.
3. Outline the use of the function in C?
A function is a block of code which only runs when it is called. You can pass data, known as
parameters, into a function. Functions are used to perform certain actions, and they are important for
reusing code: Define the code once, and use it many times.
4. Demonstrate what is meant by recursion with example
Recursion is the process of repeating items in a self-similar way. In programming languages, if a
program allows you to call a function inside the same function, then it is called a recursive call of the
function.
5. What is meant by structure
Structure in c is a user-defined data type that enables us to store the collection of
different data types. Each element of a structure is called a member.

6. Tell how to access a member using structure


Array elements are accessed using the Subscript variable, Similarly Structure
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
members are accessed using dot [.] operator. Structure written inside another structure is
called as nesting of two structures.
7. Write a brief note on typedef
The typedef is a keyword used in C programming to provide some meaningful names
to the already existing variable in the C program.

8. What is Union
Union is a user-defined data type, just like a structure. Union combines objects of different
types and sizes together. The union variable allocates the memory space equal to the space to
hold the largest variable of union. It allows varying types of objects to share the same location

9. Differences between structure and union:


Struct Union
The struct keyword is used to define a The union keyword is used to define
structure. union.
When the variables are declared in a structure, When the variable is declared in the union,
the compiler allocates memory to each the compiler allocates memory to the largest
size variable member.
variables member. The size of a structure is
The size of a union is equal to the size of its
equal or greater to the sum of the sizes of largest data member size.
each data member.
Each variable member occupied a Variables members share the memory space
unique memory space. of the largest size variable.
Changing the value of a member will not Changing the value of one member will
affect other variables members. also affect other variables members.
Each variable member will be assessed at a Only one variable member will be
time. assessed at a time.
We can initialize multiple variables of a In union, only the first data member can
structure at a time. be initialized.
All variable members store some value at any Exactly only one data member stores a
point in the program. value at any particular instance in the
program.
The structure allows initializing multiple Union allows initializing only one
variable members at once. variable member at once.
It is used to store different data type It is used for storing one at a time from
values. different data type values.
It allows accessing and retrieving any data It allows accessing and retrieving any one
member at a time. data member at a time.

10. Define Enumerated Data type


Enumeration or Enum in C is a special kind of data type defined by the user. It
consists of constant integrals or integers that are given names by a user. The use of enum
in C to name the integer values makes the entire program easy to learn, understand, and
maintain by the same or even different programmer.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

11. What is a Structure in C?


Structure is a user-defined datatype in C language which allows us to combine data of
different types together. Structure helps to construct a complex data type which is more
meaningful. In structure, data is stored in form of records.

12. How to define a Structure?


struct keyword is used to define a structure. struct defines a new data type which is a
collection of primary and derived data types.
Syntax
struct [structure_tag]
{
//member variable 1
//member variable 2
//member variable 3
...
}[structure_variables];

13. What is Union?


A union is a special data type available in C that allows to store different data types in
the same memory location. You can define a union with many members, but only one
member can contain a value at any given time. Unions provide an efficient way of using the
same memory location for multiple purpose.

14. Give the syntax for creating a union.


union [union name]
{
member definition;
member definition;
...
member definition;
};

15. Difference between Structure and Union.


Structure Union
The Keyword struct is used to The Keyword union is used to
define the Structure define the Union
Structure allocates storage space for Union allocates one storage space
all its members seperately. for all its members.
Structure occupies high memory Union occupies low memory space
space when compared to Structure
We can access all members of Only one member of union can be
Structure at a time accessed at a time.
Altering the value of a member will Altering the value of a member will
not affect other member of a alter other member value in union.
structure

16.What are Enumerated Datatypes?


Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to
integral constants, the names make a program easy to read and maintain.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

17. What is pointer?


A pointer is a variable that stores the memory address of another variable as its value. A pointer
variable points to a data type (like int) of the same type and is created with the * operator.

18. How addresses are assigned to Pointers?


Example
int* p, a;
a= 8;
p = &a;
Here, 8 is assigned to the variable a and the address of a is assigned to the pointer p.

19. What are the uses of Pointers?


➢ Pointers are used to return more than one value to the function
➢ Pointers are more efficient in handling the data in arrays
➢ Pointers reduce the length and complexity of the program
➢ They increase the execution speed
➢ The pointers saves data storage space in memory.

20. What is the difference between an array and pointer?


Arrays Pointers
Array allocates space automatically. Pointer is explicitly assigned to point
to an allocated space.
It cannot be resized. It can be resized using realloc ().
It cannot be reassigned. Pointers can be reassigned.
Sizeof(array name) gives the number Sizeof(pointer name) returns the
of bytes occupied by the array. number of bytes used to store the
pointer variable.

21.What is dangling pointer?


➢ In C, a pointer may be used to hold the address of dynamically allocated memory. After this
memory is freed with the free() function, the pointer itself will still contain the address of the
released block. This is referred to as a dangling pointer.
➢ Using the pointer in this state is a serious programming error. Pointer should be assigned
NULL after freeing memory to avoid this bug.

22. What is ‘C’ functions?


➢ A function is a self-contained block (or) a sub-program of one or more statements that
performs a special task when called.
➢ To perform a task repetitively then it is not necessary to re-write the particular block of the
program again and again. The function defined can be used for any number of times to perform
the task.

23. Differentiate library functions and User-defined functions.


Library Functions User-defined Functions
Library functions are pre-defined set of The User-defined functions are the
functions that are defined in C libraries. functions defined by the user according
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

to his/her requirement.
User can only use the function but User can use this type of function.
cannot change (or) modify this User can also modify this function.
function.

24. What are the steps in writing a function in a program?


➢ Function Declaration (Prototype declaration): Every user-defined function has to be
declared before the main().
➢ Function Calling: The user-defined functions can be called inside any functions like main(),
user-defined function, etc.
➢ Function Definition: The function definition block is used to define the user-defined
functions with statements.

25. What is a use of ‘return’ Keyword?


➢ The ‘return’ Keyword is used only when a function returns a value.

26. What is the purpose of the function main()?


➢ The function main () invokes other functions within it. It is the first function to be called
when the program starts execution.
➢ Features of Main method
o It is the starting function.
o It returns an int value to the environment that called the program.
o Recursive call is allowed for main () also.
o It is a user-defined function.
o Program execution ends when the closing brace of the function main() is reached.
o It has two arguments (a) argument count and (b)argument vector (represents strings passed.)

27. Compare between Array and Structure


Arrays Structures
An array is a collection of data items of A structure is a collection of data items
same data type. of different data types.
Arrays can only be declared. There is no Structures can be declared and defined.
keyword for arrays. The Keyword for structures is struct.
An array name represents the address of A structure name is known as tag. It is a
the starting element. shorthand notation of the declaration.
An array cannot have bit fields. A structure may contain bit fields.

28.Is it better to use a macro or a function?


➢ Macros are more efficient (and faster) than function because their corresponding code is
inserted directly at the point where the macro is called. There is no overhead involved in using
a macro like there is in placing a call to a function.
➢ However, macros are generally small and cannot handle large, complex coding constructs.
In cases where large, complex constructs are to handled, functions are more suited,
additionally; macros are expanded inline, which means that the code is replicated for each
occurrence of a macro.

29. List the characteristics of Arrays.


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
➢ All elements of an array share the same name, and they are distinguished form one another
with help of an element number.
➢ Any element of an array can be modified separately without disturbing other elements.

30. What are the types of Arrays?


➢ One-Dimensional Array
➢ Two-Dimensional Array
➢ Multi-Dimensional Array

31. What is File Handling in C?


➢ A file is nothing but a source of storing information permanently in the form of a sequence
of bytes on a disk. The contents of a file are not volatile like the C compiler memory. The
various operations available like creating a file, opening a file, reading a file, or manipulating
data inside a file is referred to as file handling.

32. What is the need for File Handling in C?


➢ Reusability: It helps in preserving the data or information generated after running the
program.
➢ Large storage capacity: Using files, you need not worry about the problem of storing data
in bulk.
➢ Saves time: There are certain programs that require a lot of input from the user. You can
easily access any part of the code with the help of certain commands.
➢ Portability: You can easily transfer the contents of a file from one computer system to
another without having to worry about the loss of data.

33. List some of C File Handling Operations.


➢ Creating a new file: fopen()
➢ Opening an existing file in your system: fopen()
➢ Closing a file: fclose()
➢ Reading characters from a line: getc()
➢ Writing characters in a file: putc()
➢ Reading a set of data from a file: fscanf()
➢ Writing a set of data in a file: fprintf()
➢ Reading an integral value from a file: getw()

34. Give the syntax for Opening a Text File in C.


Syntax
*fpointer = FILE *fopen(const char *file_name, const char *mode);
*fpointer is the pointer to the file that establishes a connection between the file and the
program.
*file_name is the name of the file.
*mode is the mode in which we want to open our file.

35. How to Read and Write a Text File in C?


The input/output operations in a file help you read and write in a file.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
The simplest functions used while performing operations on reading and writing characters in a
file are getc() and putc() respectively.
In order to read and write a set of data in a file, we use the fscanf() and fprintf() operators.

36. Write short notes on Preprocessor Directives.


➢ The C preprocessor is a macro processor that is used automatically by the C compiler to
transform your program before actual compilation (Preprocessor directives are executed before
compilation.).
➢ It is called a macro processor because it allows you to define macros, which are brief
abbreviations for longer constructs.

37. What is macro?


➢ A macro is a segment of code which is replaced by the value of macro. Macro is defined by
#define directive.

38. List few preprocessor directives in C.


➢ #include
➢ Macro's (#define)
➢ #undef
➢ #ifdef
➢ #ifndef
➢ #if
➢ #else

PART-B
1. Explain Structure in C with neat program.
2. Write short notes on Union with example program.
3. What is a function? Explain with neat program.
4. Explain call by value and call by reference with example programs.
5. Explain the file handling mechanism in C with programs.
6. Explain preprocessor directives with its types and examples.
7. Explain the concept of pointers with neat programs.
8. Write shorts notes on Arrays.
9. How to write Data into a text file and Read Data from the file? Discuss.
10. How to read and write data to the binary file in a program? Explain.

UNIT - III
1. Define Data Structures
Data Structures is defined as the way of organizing all data items that consider not only the
elements stored but also stores the relationship between the elements.

2. Define Linked Lists


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
Linked list consists of a series of structures, which are not necessarily adjacent in memory.
Each structure contains the element and a pointer to a structure containing its successor. We
call this theNext Pointer. The last cell’sNext pointer points to NULL.

3. State the different types of linked lists


The different types of linked list include
1. singly linked list
2. doubly linked list
3. circular linked list.

4. List out the advantages of using a linked list?


• It is not necessary to specify the number of elements in a linked list during its
declaration
• Linked list can grow and shrink in size depending upon the insertion and deletion that
occurs in the list
• Insertions and deletions at any place in a list can be handled easily and efficiently • A
linked list does not waste any memory space

5.State the difference between arrays and linked lists


Arrays Linked Lists
Size of an array is fixed Size of a list is variable
It is necessary to specify the number It is not necessary to specify the
of elements during declaration number of elements during
declaration
Insertions and deletions are somewhat Insertions and deletions are carried
difficult out easily
It occupies less memory than a linked It occupies more memory
list for the same number of elements

6. Define an Abstract Data Type (ADT)


An abstract data type is a set of operations. ADTs are mathematical abstractions;
nowhere in an ADT’s definition is there any mention of how the set of operations is
implemented. Objects such as lists, sets and graphs, along with their operations can be viewed
as abstract data types.

7. Define a stack
Stack is an ordered collection of elements in which insertions and deletions are
restricted to one end. The end from which elements are added and/or removed is referred to as
top of the stack. Stacks are also referred as piles, push- down lists and last-in-first out (LIFO)
lists.

8. List out the basic operations that can be performed on a stack :


The basic operations that can be performed on a stack are
• Push operation
• Pop operation
• Peek operation
• Empty check
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
• Fully occupied check

9. State the rules to be followed during infix to postfix conversions :


• Fully parenthesize the expression starting from left to right. During parenthesizing, the
operators having higher precedence are first parenthesized
• Move the operators one by one to their right, such that each operator replaces their
corresponding right parenthesis
• The part of the expression, which has been converted into postfix is to be treated as
single operand

10. Define a queue


Queue is an ordered collection of elements in which insertions are restricted to one end
called the rear end and deletions are restricted to other end called the front end. Queues are
also referred as First-In-First-Out (FIFO) Lists.

11. What do you mean by non-linear data structure? Give example.


The non-linear data structure is the kind of data structure in which the data may be arranged in
hierarchical fashion. For example- Trees and graphs.

12. List the various operations that can be performed on data structure.
➢ Various operations that can be performed on the data structure are
• Create
• Insertion of element
• Deletion of element
• Searching for the desired element
• Sorting the elements in the data structure
• Reversing the list of elements.

13. What is abstract data type


➢ The abstract datatype is special kind of datatype, whose behavior is defined by a set of
values and set of operations.

14. What is list ADT in data structure?


➢ The list ADT is a collection of elements that have a linear relationship with each other. A
linear relationship means that each element of the list has a unique successor.

15. What Are Arrays in Data Structures?


➢ An array is a linear data structure that collects elements of the same data type and stores
them in contiguous and adjacent memory locations. Arrays work on an index system starting
from 0 to (n-1), where n is the size of the array.

16. What is a linked list?


➢ A linked list is a set of nodes where each node has two fields ‘data’ and ‘link’. The data field
is used to store actual piece of information and link field is used to store address of next node.

17. What are the pitfall encountered in singly linked list?


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
➢ The singly linked list has only forward pointer and no backward link is provided. Hence the
traversing of the list is possible only in one direction. Backward traversing is not possible.
➢ Insertion and deletion operations are less efficient because for inserting the element at
desired position the list needs to be traversed. Similarly, traversing of the list is required for
locating the element which needs to be deleted.

18. What is Singly Linked List?


➢ A singly linked list is a type of linked list that is unidirectional, that is, it can be traversed in
only one direction from head to the last node (tail).

19. Define doubly linked list.


➢ Doubly linked list is a kind of linked list in which each node has two link fields. One link
field stores the address of previous node and the other link field stores the address of the next
node.

20. Write down the steps to modify a node in linked lists.


o Enter the position of the node which is to be modified.
o Enter the new value for the node to be modified.
o Search the corresponding node in the linked list.
o Replace the original value of that node by a new value.
o Display the messages as “The node is modified”.

21. Difference between arrays and lists.


➢ In arrays any element can be accessed randomly with the help of index of array,
whereas in lists any element can be accessed by sequential access only.
➢ Insertion and deletion of data is difficult in arrays on the other hand insertion and
deletion of data is easy in lists.

22. State the properties of LIST abstract data type with suitable example.
➢ It is linear data structure in which the elements are arranged adjacent to each other.
➢ It allows to store single variable polynomial.
➢ If the LIST is implemented using dynamic memory, then it is called linked list.
Example of LIST are- stacks, queues, linked list.

23. State the advantages of circular lists over doubly linked list.
➢ In circular list the next pointer of last node points to head node, whereas in doubly linked
list each node has two pointers: one previous pointer and another is next pointer.
➢ The main advantage of circular list over doubly linked list is that with the help of single
pointer field we can access head node quickly. Hence some amount of memory get saved
because in circular list only one pointer is reserved.

24. What are the advantages of doubly linked list over singly linked list?
➢ The doubly linked list has two pointer fields. One field is previous link field, and another is
next link field. Because of these two pointer fields we can access any node efficiently whereas
in singly linked list only one pointer field is there which stores forward pointer.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
25. Why is the linked list used for polynomial arithmetic?
➢ We can have separate coefficient and exponent fields for representing each term of
polynomial. Hence there is no limit for exponent. We can have any number as an exponent.

26. What is the advantage of linked list over arrays?


➢ The linked list makes use of the dynamic memory allocation. Hence the user can allocate or
de allocate the memory as per his requirements. On the other hand, the array makes use of the
static memory location. Hence there are chances of wastage of the memory or shortage of
memory for allocation.

27. What is the circular linked list?


➢ The circular linked list is a kind of linked list in which the last node is connected to the first
node or head node of the linked list.

28. What is the basic purpose of header of the linked list?


➢ The header node is the very first node of the linked list. Sometimes a dummy value such -
999 is stored in the data field of header node.
➢ This node is useful for getting the starting address of the linked list.

29. What is the advantage of an ADT?


➢ Change: the implementation of the ADT can be changed without making changes in the
client program that uses the ADT.
➢ Understandability: ADT specifies what is to be done and does not specify the
implementation details. Hence code becomes easy to understand due to ADT.
➢ Reusability: the ADT can be reused by some program in future.

30. What is queue ADT?


➢ Queue is an abstract data structure, somewhat like Stacks. Unlike stacks, a queue is open at
both its ends. One end is always used to insert data (enqueue) and the other is used to remove
data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first
will be accessed first.

31. What is priority queue


➢ A priority queue is a special type of queue in which each element is associated with a
priority value. Elements are served on the basis of their priority. That is, higher priority
elements are served first. However, if elements with the same priority occur, they are served
according to their order in the queue.

32. What is stack?


➢ Stack is an abstract data type that serves as a collection of elements, with two main
operations: Push, which adds an element to the collection, and Pop, which removes the most
recently added element that was not yet removed.

33. How is Stack represented in Data Structure?


➢ A stack may be represented in the memory in various ways. There are two main ways: using
a one-dimensional array and a single linked list.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE

34. List some applications of queue data structure.


➢ Managing requests on a single shared resource such as CPU scheduling and disk scheduling.
➢ Handling hardware or real-time systems interrupts.
➢ Handling website traffic.
➢ Routers and switches in networking.
➢ Maintaining the playlist in media players.

35. List some applications of stack data structure.


➢ A Stack can be used for evaluating expressions consisting of operands and operators.
➢ Stacks can be used for Backtracking, i.e., to check parenthesis matching in an expression.
➢ It can also be used to convert one form of expression to another form. It can be used for
systematic Memory Management.

PART B
1. Explain Singly Link List with algorithm and examples.
2. How insertion and deletion are performed on a singly linked list? Explain with pseudocode
and examples
3. Explain Doubly Linked List with examples and algorithms.
4. Explain Array based implementation of List ADT with examples and pseudocode.
5. Explain Array based implementation of Stack ADT with examples.
6. Demonstrate the implementation of circular linked list with examples.
7. Explain the applications of stack with examples.
8. Write short notes on queue ADT.
9. How are insertion and deletion operations performed in a queue? Explain with examples and
pseudocode.
10. Explain the implementation of priority queue with examples and pseudocode.
11. Explain queue implementation using linked list with pseudocode and examples.
12. Explain queue implementation using stack with pseudocode and examples.

UNIT -IV
1. Define a tree
A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists
of a distinguished node r, called the root, and zero or more nonempty (sub) trees T1, T2,…,Tk,
each of whose roots are connected by a directed edge from r.

2. Define root
This is the unique node in the tree to which further sub-trees are attached.

B
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
Here, A is the root.

3 . Define a binary tree


A binary tree is a finite set of nodes which is either empty or consists of a root and two
disjoint binary trees called the left sub-tree and right sub-tree.

4.State the properties of a binary tree


• The maximum number of nodes on level n of a binary tree is 2n-1, where n≥1.
• The maximum number of nodes in a binary tree of height n is 2n-1, where n≥1.
• For any non-empty tree, nl=nd+1 where nl is the number of leaf nodes and nd is the
number of nodes of degree 2.

5 . What is meant by binary tree traversal?


Traversing a binary tree means moving through all the nodes in the binary tree, visiting
each node in the tree only once.

6. What are the tasks performed during inorder traversal?


• Traverse the left sub-tree
• Process the root node
• Traverse the right sub-tree

7. Define binary tree?


➢ A binary tree is a tree data structure composed of nodes, each of which has utmost, two
children, referred to as left and right nodes. The tree starts off with a single node known as the
root.

8. What are the two methods of binary tree implementation?


➢ Linear representation.
➢ Linked representation

9. What are the applications of binary tree?


➢ Binary tree is used in data processing.
o File index schemes
o Hierarchical database management system

10. List out few of the Application of tree data-structure?


➢ The manipulation of Arithmetic expression
➢ Used for Searching Operation
➢ Used to implement the file system of several popular operating systems
➢ Symbol Table construction
➢ Syntax analysis

11. Define expression tree?


➢ Expression tree is also a binary tree in which the leaf’s terminal nodes or operands and non-
terminal intermediate nodes are operators used for traversal.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
12. Define tree– traversal and mention the type of traversals?
➢ Three types of tree traversal
• Inorder traversal
• Preoder traversal
• Postorder traversal.

13. Define in -order traversal?


➢ In-order traversal entails the following steps;
• Traverse the left subtree
• Visit the root node
• Traverse the right subtree

14. What is pre-order traversal?


➢ In preorder traversal, first, root node is visited, then left sub-tree and after that right sub-tree
is visited. The process of preorder traversal can be represented as: root → left → right

15. Define threaded binary tree.


➢ A binary tree is threaded by making all right child pointers that would normally be null point
to the in order successor of the node, and all left child pointers that would normally be null
point to the in-order predecessor of the node.

16. What are the types of threaded binary tree?


➢ Right-in threaded binary tree
➢ Left-in threaded binary tree
➢ Fully-in threaded binary tree

17. Define Binary Search Tree.


➢ Binary search tree is a binary tree in which for every node X in the tree, the values of all the
keys in its left subtree are smaller than the key value in X and the values of all the keys in its
right subtree are larger than the key value in X.

18. What is AVL Tree?


➢ AVL stands for Adelson-Velskii and Landis. An AVL tree is a binary search tree which has
the following properties:
• The sub-trees of every node differ in height by at most one.
• Every sub-tree is an AVL tree.

19. List out the steps involved in deleting a node from a binary search tree.
➢ Deleting a node is a leaf node (ie) No children
➢ Deleting a node with one child.
➢ Deleting a node with two Childs.

20. Define complete binary tree.


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
➢ If all its levels, possible except the last, have maximum number of nodes and if all the nodes
in the last level appear as far left as possible

21. Write short notes on Expression Trees.


➢ A binary expression tree is a specific kind of a binary tree used to represent expressions.
➢ Two common types of expressions that a binary expression tree can represent are algebraic
and boolean. These trees can represent expressions that contain both unary and binary
operators.

22. What is Hashing?


➢ Hashing is a technique of mapping a large chunk of data into small tables using a hashing
function. It is also known as the message digest function. It is a technique that uniquely
identifies a specific item from a collection of similar items.

23. What is Hash Function?


➢ A hash function is a function that takes a set of inputs of any arbitrary size and fits them into
a table or other data structure that contains fixed-size elements.

24. List the advantages of hashing in data structure


➢ Hash provides better synchronization than other data structures. Hash tables are more
efficient than search trees or other data structures. Hash provides constant time for searching,
insertion and deletion operations on average.

25. What is separate chaining?


➢ Separate Chaining is one of the techniques that is used to resolve the collision. It is
implemented using linked lists.
➢ This method combines a linked list with a hash table in order to resolve the collision. In this
method, we put all the elements that hash to the same slot in the linked list.

26. What is open addressing in hashing?


➢ In open addressing,
• Unlike separate chaining, all the keys are stored inside the hash table.
• No key is stored outside the hash table.

27. List the techniques used in open addressing.


➢ Linear Probing
➢ Quadratic Probing
➢ Double Hashing

28. What is Linear Probing?


➢ Linear probing is a scheme in computer programming for resolving collisions in hash tables,
data structures for maintaining a collection of key–value pairs and looking up the value
associated with a given key.

29. Write short notes on Quadratic Probing?


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
➢ Quadratic probing is an open addressing scheme in computer programming for resolving
hash collisions in hash tables.
➢ Quadratic probing operates by taking the original hash index and adding successive values
of an arbitrary quadratic polynomial until an open slot is found.

30. Explain about Double Hashing.


➢ Double hashing is a collision resolving technique in Open Addressed Hash tables. Double
hashing uses the idea of applying a second hash function to key when a collision occurs.

31. What is rehashing in data structure?


➢ Rehashing is a technique in which the table is resized, i.e., the size of table is doubled by
creating a new table.

32. List the advantages of Double hashing


➢ The advantage of Double hashing is that it is one of the best form of probing, producing a
uniform distribution of records throughout a hash table.
➢ This technique does not yield any clusters.
➢ It is one of effective method for resolving collisions.

PART-B
1. Explain the tree traversal techniques with an example.
2. Construct an expression tree for the expression (a+b*c) + ((d*e+f)*g). Give the outputs when
you apply inorder, preorder and postorder traversals.
3. How to insert and delete an element into a binary search tree and write down the code for the
insertion routine with an example.
4. Create a binary search tree for the following numbers start from an empty binary search tree.
45,26,10,60,70,30,40 Delete keys 10, 60 and 45 one after the other and show the trees at each
stage.
5. Explain Open Addressing techniques in detail.

UNIT -V
1. Define sorting
Sorting arranges the numerical and alphabetical data present in a list in a specific order or
sequence. There are a number of sorting techniques available. The algorithms can be chosen based
on the following factors – Size of the data structure – Algorithm efficiency – Programmer’s
knowledge of the technique.

2. Mention the types of sorting


 Internal sorting
 External sorting

3. Define bubble sort


Bubble sort is a simple sorting algorithm that works by repeatedly stepping through the list to be
sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order.
ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
The pass through the list is repeated until no swaps are needed, which indicates that the list is
sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list

4. What are the steps in quick sort?


The steps are:
a. Pick an element, called a pivot, from the list.
b. Reorder the list so that all elements with values less than the pivot come before the pivot,
while all elements with values 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. c. Recursively apply the above steps to the sub-list of elements with
smaller values and separately to the sub-list of elements with greater values.

5. What are the advantages of insertion sort


Advantages
a. Simplest sorting technique and easy to implement
b. It performs well in the case of smaller lists.
c. It leverages the presence of any existing sort pattern in the list
Disadvantages
 Efficiency of O(n ) is not well suited for large sized lists
 It requires large number of elements to be shifted

6. Define searching
Searching refers to determining whether an element is present in a given list of elements or not. If
the element is present, the search is considered as successful, otherwise it is considered as an
unsuccessful search. The choice of a searching technique is based on the following factors
a. Order of elements in the list i.e., random or sorted
b. Size of the list

7. Mention the types of searching


The types are
 Linear search
 Binary search

8. What is meant by linear search?


Linear search or sequential search is a method for finding a particular value in a list that
consists of checking every one of its elements, one at a time and in sequence, until the desired one
is found.

9. What is open addressing?


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
Open addressing is also called closed hashing, which is an alternative to resolve the
collisions with linked lists. In this hashing system, if a collision occurs, alternative cells are tired
until an empty cell is found.
There are three strategies in open addressing:
 Linear probing
 Quadratic probing
 Double hashing

10. Define Hashing.


Hashing is the transformation of string of characters into a usually shorter fixed length
value or key that represents the original string. Hashing is used to index and retrieve items in a
database because it is faster to find the item using the short hashed key than to find it using the
original value.

11.What is sorting?
➢ Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to
arrange data in a particular order.

12. Define insertion sort?


➢ Successive element in the array to be sorted and inserted into its proper place with respect to the
other already sorted element. We start with second element and put it in its correct place, so that
the first and second elements of the array are in order.

13. Write short notes on quick sort.


➢ Quicksort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the
array and partitioning the other elements into two sub-arrays, according to whether they are less
than or greater than the pivot. For this reason, it is sometimes called partition-exchange sort.

14. What is Merge sort?


➢ The Merge Sort function repeatedly divides the array into two halves until we reach a stage
where we try to perform Merge Sort on a subarray of size 1

15. What is Time Complexity for Merge Sort?


➢ Merge Sort is an efficient, stable sorting algorithm with an average, best-case, and worst-case
time complexity of O(n log n).

16. What is Linear Search?


➢ The Linear search algorithm works by sequentially iterating through the whole array or list from
one end until the target element is found.
➢ If the element is found, it returns its index, else -1.

17. What is binary Search?


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
➢ Binary search follows the divide and conquer approach in which the list is divided into two
halves, and the item is compared with the middle element of the list. If the match is found then, the
location of the middle element is returned. Otherwise, we search into either of the halves
depending upon the result produced through the match.
➢ Binary search can be implemented only on a sorted list of items. If the elements are not sorted
already, we need to sort them first.

18. What is Heap Sort?


➢ Heap sort is a comparison-based sorting technique based on Binary Heap data structure.
➢ It is like the selection sort where we first find the minimum element and place the minimum
element at the beginning. Repeat the same process for the remaining elements.

19. What is Time Complexity for Heap Sort?


➢ The time complexity for Heap sort in average, best-case, and worst-case time complexity of O(n
log n).

20. What is Time Complexity for Insertion Sort?


Algorithm Best Case Average Case Worst Case
Insertion Sort O(n) O(n2) O(n2)

21. Why quick sort is preferred for arrays and merge sort for linked lists?
➢ Quick sort is an in-place sorting algorithm, i.e. which means it does not require any additional
space, whereas Merge sort does, which can be rather costly. In merge sort, the allocation and
deallocation of the excess space increase the execution time of the algorithm.
➢ Unlike arrays, in linked lists, we can insert elements in the middle in O(1) extra space and O(1)
time complexities if we are given a reference/pointer to the previous node. As a result, we can
implement the merge operation in the merge sort without using any additional space.

22. In which case insertion sort is used?


➢ Insertion sort has a fast best-case running time and is a good sorting algorithm to use if the input
list is already mostly sorted.

23. What is the advantage of using Quick sort algorithm?


➢ Quick sort reduces unnecessary swaps and moves an item to a greater distance, in one move.

24. Mention the various types of searching techniques in C.


➢ Linear search
➢ Binary search

25. Define Searching.


➢ Searching in data structure refers to the process of finding the required information from a
collection of items stored as elements in the computer memory.
➢ These sets of items are in different forms, such as an array, linked list, graph, or tree.

26. Compare Quick sort and Merge Sort.


ANAND INSTITUTE OF HIGHER TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
An ISO 9001:2008 Certified Institution & Accredited by NBA
DEPARTMENT OF ECE
Basis for comparison Quick Sort Merge Sort
Efficiency Inefficient for larger More efficient
arrays
Sorting method Internal External
Stability Not Stable Stable
Preferred for for Arrays for Linked Lists

PART - B
1. Explain Insertion sort with algorithm and examples.
2. Sort the sequence 13,11,74,37,85,39,22,56,25 using insertion sort.
3. Explain the operation and implementation of merge sort.
4. Write quick sort algorithm and explain with an example.
5. Trace the quick sort algorithm for the following list of numbers. 90,77,60,99,55,88,66
6. Explain linear search algorithm with an example.
7. Explain Binary search algorithm with an example.
8. Write down the merge sort algorithm and give its worst case, best case and average case
analysis.
9. Explain Heap Sort algorithm with an example

You might also like