0% found this document useful (0 votes)
9 views10 pages

CS3353 QB

The document provides an overview of C programming and data structures, covering topics such as data types, variables, operators, pointers, functions, arrays, linked lists, stacks, queues, trees, and sorting algorithms. It explains key concepts, definitions, and differences between various data structures and operations. Additionally, it discusses advantages and disadvantages of certain structures and algorithms, along with their applications.

Uploaded by

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

CS3353 QB

The document provides an overview of C programming and data structures, covering topics such as data types, variables, operators, pointers, functions, arrays, linked lists, stacks, queues, trees, and sorting algorithms. It explains key concepts, definitions, and differences between various data structures and operations. Additionally, it discusses advantages and disadvantages of certain structures and algorithms, along with their applications.

Uploaded by

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

www.Notesfree.

in

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

n
Variables are containers for storing data values. In C, there are
different types of variables (defined with different keywords), for

e.i
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.
fre
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
tes
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
No

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

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
ww

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.

www.Notesfree.in
www.Notesfree.in

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

n

• for loop

e.i
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. fre
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
tes
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
No

want to store 100 integers, you can create an array for it.
int data[100];
w.

UNIT -II
1.What is a pointer? give examples
A pointer is a variable that stores the address of another variable.
ww

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.

www.Notesfree.in
www.Notesfree.in

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

n
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

e.i
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
fre
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.
tes
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.
No

6. Tell how to access a member using structure


Array elements are accessed using the Subscript variable, Similarly
w.

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

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.

www.Notesfree.in
www.Notesfree.in

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
When the variable is declared in the
structure, the compiler allocates
union, the compiler allocates memory
memory to each variables member. The
to the largest size variable member.
size of a structure is equal or greater to

n
The size of a union is equal to the size
the sum of the sizes of each data
of its largest data member size.
member.

e.i
Each variable member occupied a Variables members share the memory
unique memory space. space of the largest size variable.
Changing the value of one member
Changing the value of a member will
not affect other variables members. fre will also affect other variables
members.
Each variable member will be assessed Only one variable member will be
at a time. assessed at a time.
tes
We can initialize multiple variables of a In union, only the first data member
structure at a time. can be initialized.
Exactly only one data member stores
All variable members store some value
a value at any particular instance in
at any point in the program.
the program.
No

The structure allows initializing Union allows initializing only one


multiple 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
values. from different data type values.
w.

It allows accessing and retrieving any It allows accessing and retrieving any
data member at a time. one data member at a time.
ww

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.

www.Notesfree.in
www.Notesfree.in

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
Linked list consists of a series of structures, which are not necessarily

n
adjacent in memory. Each structure contains the element and a pointer to a
structure containing its successor. We call this theNext Pointer. The last

e.i
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.
fre
4.List out the advantages of using a linked list?
tes
• 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
No

efficiently • A linked list does not waste any memory space

5.State the difference between arrays and linked lists


Arrays Linked Lists
w.

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
ww

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.

www.Notesfree.in
www.Notesfree.in

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

n
• Push operation
• Pop operation

e.i
• Peek operation
• Empty check
• Fully occupied check

fre
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
tes
• The part of the expression, which has been converted into postfix is to
be treated as single operand

10.Define a queue
No

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.
w.
ww

www.Notesfree.in
www.Notesfree.in

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.

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

e.i
A

B fre
tes
Here, A is the root.

3 . Define a binary tree


No

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

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

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

www.Notesfree.in
www.Notesfree.in

7. Define a binary search tree


A binary search tree is a special binary tree, which is either empty or it
should satisfy the following characteristics: Every node has a value and no two
nodes should have the same value i.e) the values in the binary search tree are
distinct
• The values in any left sub-tree is less than the value of its parent
node
• The values in any right sub-tree is greater than the value of its
parent node

n
• The left and right sub-trees of each node are again binary search
trees

e.i
8. List out the disadvantages of using a linked list
• Searching a particular element in a list is difficult and time consuming
• A linked list will use more storage space than an array to store the same
number of elements fre
9. List out the applications of a linked list
Some of the important applications of linked lists are manipulation of
polynomials, sparse matrices, stacks and queues.
tes
10.Define a Deque
Deque (Double-Ended Queue) is another form of a queue in which
insertions and deletions are made at both the front and rear ends of the queue.
No

There are two variations of a deque, namely, input restricted deque and output
restricted deque. The input restricted deque allows insertion at one end (it can
be either front or rear) only. The output restricted deque allows deletion at one
end (it can be either front or rear)
w.
ww

www.Notesfree.in
www.Notesfree.in

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

n
• Internal sorting
• External sorting

e.i
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
fre
swapping them if they are in the wrong order. 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
tes
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
No

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

5.What are the advantages of insertion sort


Advantages
a. Simplest sorting technique and easy to implement
ww

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

www.Notesfree.in
www.Notesfree.in

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

n
The types are
• Linear search

e.i
• Binary search

8. What is meant by linear search?


Linear search or sequential search is a method for finding a particular
fre
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?


Open addressing is also called closed hashing, which is an alternative
tes
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
No

• 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
w.

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

www.Notesfree.in

You might also like