Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes DTM,DSU,C,C++ (DSU)

Rating
-
Sold
-
Pages
13
Uploaded on
23-10-2024
Written in
2024/2025

It contains important questions on linkedlist

Institution
Course

Content preview

Q1.Define memory allocation and explain its type:

Ans.

Memory allocation is a process by which a particular computer program is allocated memory
space. The memory allocation is done either before or at the time of program execution.
• There are two types of memory allocations in C language namely, static (at
compiletime) and dynamic (run-dme).
• When the allocation of memory performs at the compile-time, then it is known as static
memory allocation.
• Array is a data structure where elements are stored in consecutive memory locations. In
order to occupy the consecutive memory space, block of memory that is required for the
array should be allocated before it use.
• Once memory is located it cannot be changed any more. This is why array is known as
static data structure.
• When the memory allocation is done at the execution or run-time, then it is called
dynamic memory allocation.
• The linked list is called dynamic data structure where amount of memory' required can
be changed during its use.
• Linked list can grow or shrink during the execution of a program. In C language, memory
can be allocated dynamically by calling malloc(), calloc() or realloc() functions.

Q2.Write down difference between static and dynamic memory allocation:

Static memory allocation Dynamic memory allocation
1.In static memory allocation the memory is 1. In dynamic memory allocation the memory
allocated at the compile time. is allocated at the run-time.

2. Static memory allocation is done before 2. Dynamic memory allocation is done during
program execution (i.e., during compile- program execution.
time).

3. Static memory allocation allots memory 3.Dynamic memory allocation allots memory
from the stack. from the heap.
4. It is less emcient and execution of the
4.It is more efficient and execution is slow.
program is fast.
5.In static memory allocation once the 5. The memory can be allotted at any time in
memory is allotted, it Will remain from the program (user can allocate more memorj,
beginning to end of the program. when required as well as release the memory)

, 6. In static memory allocation the memory is 6. In dynamic memory allocation the memory
allocated automatically by the compiler when is allocated only when there is an explicit call
the definition of statements is encountered. to malloc() and calloc() functions
7.Static memory allocation is preferred/used in 7. Dynamic memory allocation is
an array. preferred/used in the linked list
8.In static memory allocation, the allocated 8. In dynamic memory allocation, executing a
memory cannot be changed while executing a program, the allocated memory can be
Program. changed.




Q3.Define linkedlist and list its advantages and disadvantages:

Ans.

• Linkedlist is a collection of n number of data which is implemented using the concept of
dynamic memory allocation.
• Linkedlist provides us the facility to stored as many as elements we want to stored.
• This enable us to create memory during run time which is also known as concept of
dynamic memory allocation.
• Types:singlelinkedlist,doublylinkedlist,circularlinkedlist
• Declaration:
Struct node
{
Int data;
Struct node *link;
}*start=NULL;
• Representation:

Written for

Institution
Course

Document information

Uploaded on
October 23, 2024
Number of pages
13
Written in
2024/2025
Type
Class notes
Professor(s)
Shelar
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
siddhishelar

Get to know the seller

Seller avatar
siddhishelar
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions