+1 (315) 557-6473 

Professional A Stack Assignment Help

We have all the resources and expertise needed to provide you with professional A stack assignment help service. You can count on our seasoned A stack homework experts to deliver tailor-made solutions that are in line with your instructions. Our tutors are talented programmers who are well-versed in all the concepts and topics of A stack. Get our A stack homework help service now and say hello to a stress-free college life.

Implementing A Stack in C

A stack is a last-in-first-out data structure. You’ll implement a stack using a singly-linked list. You’ll use the stack to store name/value pairs, as described below.
Use this #define:
#define MAX_NAME_LENGTH 32
and use this structure:
typedef struct StackNodeStruct {
char name[MAX_NAME_LENGTH];
int value;
struct StackNodeStruct *next;
} StackNode;

Writing  Singly-linked List

Write functions to maintain a singly-linked list.
Here are four functions to write:
int stackPush(StackNode **stack, char *name, int value)
This function will create a new node containing the given name and value and push that node onto the stack.
The function should always return 0.
StackNode *stackPop(StackNode **stack)
If the stack is not empty, then this function will pop the top node o of the stack and return it. Otherwise, it will return NULL.
StackNode *stackRemoveBottomNode(StackNode **stack)
If the stack is not empty, then this function will remove the bottom node (i.e., the least recently inserted node) from the stack and return it. If the stack is empty, the function will return NULL.
int stackPrint(StackNode *stack)
This function prints the stack, from top to bottom. It does not change the stack. It should print the data this way:
|name| value
|name| value
|name| value
(Put the \pipe" character before and after the name string that you print out.)
If the stack is empty, then print this:
(stack is empty)

Strings in C

There is no \string" datatype in C. In C, a string is a array of characters, with a zero at the end. And, we can treat a char* as an array of characters. Thus, if the variable char *name holds the string "Vermont", then name[0] = 'V', name[1] = 'e', name[2] = 'r', ..., name[7] = 't', and name[8] = 0 (the value zero). Again, note that a pointer can be treated as an array.
To compare two strings for equality, use the strcmp() function. strcmp(s1, s2) returns 0 when the two strings are equal and nonzero if the two strings are not equal.
Copy one string to another with strcpy(targetLocation, sourceLocation).
And print the value of string using the %s format speci er. Here’s an example showing the use of the above functions:
char name1[16], name2[16];
int rc;
strcpy(name1, "John");
strcpy(name2, "Angela");
rc = strcmp(name1, name2);
// rc will be nonzero
rc = strcmp(name1, "John");
// rc will be zero
printf("the value of name1 is ’%s’\n", name1);
// this will be printed: the value of name1 is ’John’
To get the length of a string, use the strlen() function:
char name[32];
var len;
strcpy(name, "memory");
len = strlen(name);
printf("The length of the string is %d.\n", len);
This will print: The length of the string is 6.
Fiinally, #include and when you are using these functions.
What to Do
Do the actual implementations in C of the four functions above. Put your structure de nition and function prototypes in stack.netid.h, and put your code in stack.netid.c; submit these two les to Blackboard.
NOTE: you should not have a main() | only the four functions I describe above.
Run the tests in Assignments/stack/stack-tests.c (from gitlab).
Here’s the gitlab repo for the class:
https://gitlab.uvm.edu/Jason.Hibbeler/ForStudents f20/tree/master/CS201/
Compile your code either this way:
$ gcc -c stack.netid.c stack-tests.c
$ gcc stack.netid.o stack-tests.o
2
or this way:
$ gcc stack.netid.c stack-tests.c
Here’s the output you should get:
|four| 4
|three| 3
|two| 2
|one| 1
popped |four|, value = 4
popped |three|, value = 3
here is the stack:
|six| 6
|five| 5
|two| 2
|one| 1
remove from end:
|one| 1
|two| 2
|five| 5
|six| 6
now pop everything
|eight| 8
|seven| 7
here is the stack:
(stack is empty)