0% found this document useful (0 votes)
6 views4 pages

Data Stucture

The document is an answer key for a BCA Degree Examination on Data Structures using C, covering various topics such as data structures, time complexity, linked lists, trees, and searching algorithms. It includes short answer questions, programming tasks, and explanations of concepts like queues, stacks, and binary search trees. Additionally, it discusses operations on data structures and tree traversal techniques.

Uploaded by

Nisha
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)
6 views4 pages

Data Stucture

The document is an answer key for a BCA Degree Examination on Data Structures using C, covering various topics such as data structures, time complexity, linked lists, trees, and searching algorithms. It includes short answer questions, programming tasks, and explanations of concepts like queues, stacks, and binary search trees. Additionally, it discusses operations on data structures and tree traversal techniques.

Uploaded by

Nisha
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/ 4

Answer Key:

Third Semester BCA Degree Examination

BCA 3B 04—DATA STRUCTURES USING C (2019 Admissions)


Time: 2 Hours Maximum: 60 Marks

Section A - Short Answer Type Questions


(Each correct answer carries a maximum of 2 marks, Ceiling 20 Marks)

1. What is data structure ?


A data structure is a storage that is used to store and organize data. It is a way of
arranging data on a computer so that it can be accessed and updated efficiently.It
is also used for processing, retrieving, and storing data.

2. Define time complexity


Time taken by the algorithm to solve the problem. It is measured by calculating
the iteration of loops, number of comparisons, number of inputs etc.Time
complexity is a function describing the amount of time an algorithm takes in terms
of the amount of input to the algorithm.

3. Explain String.
A string is a sequence of characters stored in a contiguous memory location. strings are
treated as an array of characters with additional functionalities like concatenation,
slicing, and searching.

4. Differentiate between queue and stack.


A queue follows the FIFO (First-In-First-Out) principle, where elements are inserted at
the rear and removed from the front.
A stack follows the LIFO (Last-In-First-Out) principle, where elements are added and
removed from the top.

5. Explain how a linked list is represented in memory.


There are 2 ways to represent linked list in memory:Static and dynamic representation
A linked list is a collection of nodes where each node contains:
Data: The stored value.
Pointer: Reference to the next node in the list. Nodes are scattered in memory and
connected through pointers.

6. What are the operations on arrays


Traversal,Insertion,Deletion,Searching,Sorting
7. Write a note on binary tree.
A binary tree is a hierarchical structure where each node has at most two children (left
and right). It is used in search operations, sorting, and representing hierarchical data.

8. Explain circular linked list.


A circular linked list is a linked list where the last node points back to the first node.

9. Explain the term traversal in the context of array.


Traversal means accessing and processing each element of an array sequentially, often
for operations like searching or displaying elements.

10. What are weighted graphs.


Weighted graphs have numerical values (weights) assigned to edges, representing
distances or costs.

11. Explain sequential searching ?


Sequential searching involves checking each element of a list or array one by one until
the desired value is found or the list ends.

12. What is polish notation ?


Polish Notation is a notation form for expressing arithmetic, logic and algebraic
equations, also known as prefix notation, is a way of writing mathematical expressions
where the operator comes before its operands

Section B - Ceiling 30 Marks Each question carries 5 marks

13. Explain the classification of Data Structures


Data structures are classified into:Primitive Data Structures: Directly operated by the
computer, like integers, floats, and characters.Non-Primitive Data Structures: Derived from
primitive types and include:Linear Structures: Arrays, linked lists, stacks, and queues.Non-
Linear Structures: Trees, graphs.

14. Write a C program to implement insertion sort


#include <stdio.h>
int main()
{
int arr[5], length = 5, i, j, temp,n,key;
printf("Enter the number of elements : ");
scanf("%d",&n);
printf("Enter %d numbers : ",n);
for (i = 0; i < n; i++)
{
scanf("%d",&arr[i]);
}
for (i = 1; i < n; i++) {
key = arr[i];
j = i - 1;
while (key < arr[j] && j >= 0) {
arr[j + 1] = arr[j];
--j;
}
arr[j + 1] = key;
}
printf("Sorted array is : ");
for (i = 0; i < n; i++)
{
printf(" %d ",arr[i]);
}
return 0;
}
15. How linked list is different from array
A linked list is dynamic, allowing its size to grow or shrink during runtime, whereas
an array has a fixed size determined at the time of declaration. In a linked list,
elements (nodes) are scattered in memory and connected via pointers, while an array
stores elements in contiguous memory locations. Accessing an element in a linked list
requires sequential traversal, unlike an array where elements can be accessed directly
using an index.
16. Explain the operations of queue.
Enqueue: Insert an element at the rear.
Dequeue: Remove an element from the front.
Peek/Front: Access the element at the front without removal.
isEmpty: Check if the queue is empty.
isFull: Check if the queue is full (in circular queues).
17. Explain how binary search tree is represented in memory
A binary search tree (BST) is represented using nodes, where each node contains:
Data: The value stored in the node.Left Pointer: Points to the left child.Right Pointer:
Points to the right child.
The root node is the entry point. Nodes with smaller values than their parent are stored in the
left subtree, and larger values are in the right subtree.
18. Discuss how recursion works with the help of an example
Recursion is a process where a function calls itself to solve a smaller instance of the
same problem
int factorial(int n)
{ if (n == 0) return 1; return n * factorial(n - 1); }
19. Describe the applications of stack.
Polish notation
a. Infix to postfix conversion
b. Infix to Prefix conversion
c. Evaluation of Postfix expression Recursion.
Section C - 10 MarksAnswer any one question
20. Explain the basic operations of doubly (two way) linked list (creation, insertion, deletion).
Creation:
A doubly linked list is created by allocating nodes dynamically. Each node consists of three parts:

• Data: Stores the element's value.


• Prev Pointer: Points to the previous node in the list.
• Next Pointer: Points to the next node in the list.

Example: Initialize a head node with NULL values for prev and next.

Insertion:

• At the Beginning: Create a new node, set its next to point to the current head, and update the
head's prev to point to the new node.
• At the End: Traverse to the last node, create a new node, set the last node's next to the new
node, and the new node's prev to the last node.
• In the Middle: Traverse to the desired position, update pointers of adjacent nodes, and link the
new node.

• Deletion:

• From the Beginning: Update the head to point to the next node and set the new head's prev to
NULL.
• From the End: Traverse to the last node, update the second-last node's next to NULL, and free
the last node.
• From the Middle: Adjust the prev and next pointers of adjacent nodes to bypass the node to
be deleted, and then free the node.

21. Explain the different tree traversal techniques.

Tree traversal is the process of visiting all nodes in a tree in a systematic order. The common
techniques are: Depth-First Traversals

1. Inorder Traversal (Left-Root-Right):


o Visit the left subtree, the root node, and then the right subtree.
o Example: For a BST, this traversal gives nodes in ascending order.
2. Preorder Traversal (Root-Left-Right):
o Visit the root node first, then the left subtree, followed by the right subtree.
o Used to create a copy of the tree or represent it in prefix notation.
3. Postorder Traversal (Left-Right-Root):
o Visit the left subtree, then the right subtree, and finally the root node.
o Commonly used in deleting or freeing nodes in a tree.

Level Order Traversal (Breadth-First):

Traverse nodes level by level from top to bottom, left to right.Implemented using a queue.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy