CS3353 QB
CS3353 QB
in
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);
www.Notesfree.in
www.Notesfree.in
• 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
(iv) Pointers are helpful in traversing through arrays and character strings. The
strings are also arrays of characters terminated by the null character (‘\O’).
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
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
8. What is Union
www.Notesfree.in
www.Notesfree.in
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
It allows accessing and retrieving any It allows accessing and retrieving any
data member at a time. one data member at a time.
ww
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.
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
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.
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
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.
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
www.Notesfree.in
www.Notesfree.in
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.
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.
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
• 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