Escolar Documentos
Profissional Documentos
Cultura Documentos
Structures in C
Individual Assignment
Student Name
Student ID
TP035926
Module Name
Structures in C
Module Code
Intake Code :
APT1F1506CYB
Lecture
Due Date
Table of Contents
Individual Assignment
CE00894-4-ADSC
Introduction................................................................................................................ 3
Explanations............................................................................................................... 4
Part A....................................................................................................................... 4
Dijkshtras Algorithm............................................................................................ 4
Depth First Traversal............................................................................................ 6
Breadth First Traversal.......................................................................................... 8
Part B..................................................................................................................... 11
Data Structures.................................................................................................. 11
Output...................................................................................................................... 12
Conclusion................................................................................................................ 13
References................................................................................................................ 14
Page 2 of 14
Individual Assignment
CE00894-4-ADSC
Introduction
C programming is defined as a structured, procedural programming language that has been
widely used both for operating systems and applications and that has had a wide following in the
academic community. (TechTarget, 2008)
In this documentation, it will cover all part A, part B and the output of the program.
Page 3 of 14
Individual Assignment
CE00894-4-ADSC
Explanations
Part A
Dijkshtras Algorithm
50
50
60
130
100
100
100
100
Page 4 of 14
Individual Assignment
CE00894-4-ADSC
1. E F
6. E C
=EBF
=EBFC
= 60
= 70
2. E G
= 30
7.
ED
=EBFD
= 100
3. E H
=EBFCH
= 90
4. E A
=EGA
= 50
5. E B
= 50
Page 5 of 14
Individual Assignment
CE00894-4-ADSC
Starting vertex B
1.
A
G
D
C
F
B
2.D
C
F
B
G
D
C
F
B
5.
4.
C
F
B
C
F
B
7.
8.
F
B
H
C
F
B
3.
6.
9.
BFCDGAH
Page 6 of 14
Individual Assignment
CE00894-4-ADSC
Figure 1 Cities
Page 7 of 14
Individual Assignment
CE00894-4-ADSC
Starting vertex B
IN
OUT
1.
F
2.
F
W=B
3.
C
W=F
4.
W=D
5.
Page 8 of 14
Individual Assignment
CE00894-4-ADSC
W=C
6.
A
H
W=G
7.
A
W=H
8.
W=A
BFDCGHA
Figure 2 Cities
Page 9 of 14
Individual Assignment
CE00894-4-ADSC
In Breadth First Traversal, the starting vertex is B. In No. 1 B is first travel to F. Then in No. 2, B
is popped and left F. In No. 3, F is popped and then travel to C and D. In No. 4 D is popped and
then travel to G. Then in No.5, C is popped and travel to H. In No.6 G is popped and travel to A.
In No.7 H is popped. Finally, No. 8 A is popped and left and empty stack. So, the sequence is
BFDCGHA.
Part B
Data Structures
node = (struct item*)malloc(sizeof(struct item));
node->itemid = newrec.itemid;
Page 10 of 14
Individual Assignment
CE00894-4-ADSC
node->next = NULL;
When pushing the item, this code creates a memory allocation to the item that is required to
push.
In this code, the item is popped from the stacker. Where the item is unloaded from the stacker.
Output
Page 11 of 14
Individual Assignment
When
the
program
CE00894-4-ADSC
is
executed,
user
is
required
to
enter
the
truck
capacity.
Figure 4 Item ID
Conclusion
Page 12 of 14
Individual Assignment
CE00894-4-ADSC
Page 13 of 14
Individual Assignment
CE00894-4-ADSC
References
TechTarget. (2008, April). Retrieved from
http://searchwindowsserver.techtarget.com/definition/C
Page 14 of 14