In C, using malloc to allocate memory for a linked list uses which memory allocation scheme? O Heap allocation Static allocation

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question
In C, using malloc to allocate memory for a linked list uses which
memory allocation scheme?
Heap allocation
Static allocation
Transcribed Image Text:In C, using malloc to allocate memory for a linked list uses which memory allocation scheme? Heap allocation Static allocation
In C, given:
typedef struct Node {
int Data;
struct Node *Link;
} NODE_T;
NODE_T *NPtr, *Top = NULL;
int Count;
for (Count
3; Count < 6; Count++) {
malloc ( sizeof (NODE_T) );
NPtr
NPtr->Data = Count * 2;
NPtr->Link =
Тор;
= NPtr;
Тop
}
What list is created?
a) Top -> 6 -> 8 -> 10 -> NULL
b) Top -> 6 -> 8 -> 10 -> 12 -> NULL
c) Top -> 8 -> 10 -> 12 -> NULL
d) Top -> 10 -> 8 -> 6 -> NULL
e) Top -> 12
-> 10 -> 8 -> 6 -> NULL
f) Top -> 12 -> 10 -> 8 -> NULL
Transcribed Image Text:In C, given: typedef struct Node { int Data; struct Node *Link; } NODE_T; NODE_T *NPtr, *Top = NULL; int Count; for (Count 3; Count < 6; Count++) { malloc ( sizeof (NODE_T) ); NPtr NPtr->Data = Count * 2; NPtr->Link = Тор; = NPtr; Тop } What list is created? a) Top -> 6 -> 8 -> 10 -> NULL b) Top -> 6 -> 8 -> 10 -> 12 -> NULL c) Top -> 8 -> 10 -> 12 -> NULL d) Top -> 10 -> 8 -> 6 -> NULL e) Top -> 12 -> 10 -> 8 -> 6 -> NULL f) Top -> 12 -> 10 -> 8 -> NULL
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning