Starting from:

$30

CSCI215-Assignment 1 Refresher on C programming Solved

Question 1
Extract the file attached to this assignment, and compile/run the program by calling the make command in the terminal.

Question 2
Edit the Makefile to archive the array implementation of the stack as a library.

The goal is to archive the stack_array.o object file in a library libstack.a

The compilation of the final executable must now be carried out without using the object file stack_array.o

Question 3
We want to change the size of the stack at compile time, via the definition of a constant STACK_SIZE contained in the code.

Use gcc -D directive to change this value from the Makefile, and then get its display in the main program of stack_test.c

Question 4
Using an array is not satisfactory; we would prefer to use a doubly linked list.

Complete the list_impl.c file code to:

-  Extract an element from the head (the associated cell is removed from the list and the memory it occupied isdeallocated)

-  Extract an element from the tail (the associated cell is removed from the list and the memory it occupied is deallocated)

-  Compute the number of items in the list

Question 5
Write a file called stack_list.c that uses the primitives from list.h to build a dynamic stack that implements stack.h

Add a compiler directive in the makefile to build a new library libstack.a from stack_list.c and list_impl.c Recompile an executable from the stack test program (stack_test.c) and use your new library to verify that it works correctly.

Question 6
Write a file called fifo_list.c that uses the primitives from list.h to build a dynamic queue that implements fifo.h

Add a compiler directive in the makefile to build a new library libfifo.a from fifo_list.c and list_impl.c

Recompile an executable file from the test program (fifo_test.c) and use your new library to verify that it works correctly.

Question 7
Traversing the entire list to determine the number of items is too expensive. What changes should you make, and in which file(s), to determine the size of the list in O(1)?

Additional resources for assignment


%%%% Bosen

Q1 Good.

Q2 Good.

Q3 Good.

Q4 Good.

Q5 Good.

Q6

You miss something while compiling fifo_test.

Q7

Good.

More products