All the functions are written and work besides removeLinkedList
and contains LinkedList. Please fill those out. 

![/ Stack Interface/ pushLinkedList param: 1 the linked list param: val the value to be pushed pre: l is not nul] post: 1 is no](http://img.homeworklib.com/images/1a2c94dd-74ec-4c18-81f6-364dd06a2a7b.png?x-oss-process=image/resize,w_560)

// function to check if val is in linked list l
int containsLinkedList(LinkedList *l, TYPE val)
{
if(!isEmptyLinkedList(l)) // if list is empty
{
struct Link *list = l->head; //
let list point to head of linkedlist
while(list != NULL) // loop over
the list
{
if(list->val
== val) //check if val is found
return 1; // return true
list =
list->next; // set list to next node
}
}
return 0; //val not found
}
//end of containsLinkedList
// function to remove a value from linked list
void removeLinkedList(LinkedList *l, TYPE val)
{
struct Link *curr ;
struct Link *prev;
assert(containsLinkedList(l),val);
/*special case for head*/
if(l->head->val == val)
{
curr = l->head;
l->head =
l->head->next;
free(curr);
}else
{
curr = l->head->next; // set
curr to node next to head
prev = l->head; // set prev to
head
// loop over the linked list
while(curr != NULL)
{
if(curr->val
== val) // if val is found
{
prev->next = curr->next; // set the next
pointer to prev to point to node next to curr
free(curr); // delete curr
break; // break out of loop
}
prev = curr; //
set prev to curr
curr =
curr->next; // set curr to node next to curr
}
}
}
//end of removeLinkedList
All the functions are written and work besides removeLinkedList and contains LinkedList. Please fill those out. 무#ifndef #define LINKEDLIST-H LINKEDLISTH define TYPE /*# define TYPE SIZE sizeof (TYP...
Header file #ifndef DYNAMIC_ARRAY_INCLUDED #define DYNAMIC_ARRAY_INCLUDED 1 #ifndef __TYPE #define __TYPE # define TYPE int # define TYPE_SIZE sizeof(int) # endif # ifndef LT # define LT(A, B) ((A) < (B)) # endif # ifndef EQ # define EQ(A, B) ((A) == (B)) # endif typedef struct DynArr DynArr; /* Dynamic Array Functions */ void initDynArr(DynArr *v, int capacity); DynArr *newDynArr(int cap); void freeDynArr(DynArr *v); void deleteDynArr(DynArr *v); int sizeDynArr(DynArr *v); void addDynArr(DynArr *v, TYPE val); TYPE getDynArr(DynArr *v, int...
Fill the code in list.cpp app.cpp: #include "list.hpp" int main() { LinkedList aList; bool success = false; aList.evensFrontOddsEnd(3); aList.evensFrontOddsEnd(10); aList.evensFrontOddsEnd(6); aList.evensFrontOddsEnd(9); aList.evensFrontOddsEnd(17); aList.evensFrontOddsEnd(12); aList.printForward(); // output should be: 12 6 10 3 9 17 aList.printBackward(); // output should be: 17 9 3 10 6 12 success = aList.remove(17); if(success) cout << "17 Successfully Removed." << endl; success = aList.remove(10); if(success) cout << "10 Successfully Removed." << endl; success = aList.remove(7); // 7 is not in the list, so success should...
You are now going to create a LinkedList class, that will work very similarly to the Stack class seen in the book (and used in the previous exercise). Then write new methods as follows: add ( LinkedList::Link* l, int n ): will insert in the linked list, after link l, a chain of n new links. Each link will store an integer that will be set to receive, in order, a value starting from 0 until n-1. In the last...
Use the header and other files listed below for problems 1 and 2. Each problem has 3 files that correspond to the problem. Problem 1, linked list deque and bag implementations. First, complete the linked list implementation of the deque and bag ADTs in C language. To do this, implement all functions with the // FIXME... comments in linkedList.c (File included below). These functions listed are the ones that need to be fixed. init addLinkBefore removeLink linkedListAddFront linkedListAddBack linkedListFront linkedListBack...
Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list */ void...
Please rewrite this function using recursive function #include using namespace std; struct Node { char ch; Node* next; }; class LinkedList { Node* head; public: LinkedList(); ~LinkedList(); void add(char ch); bool find(char ch); bool del(char ch); friend std::ostream& operator<<(std::ostream& out, LinkedList& list); }; LinkedList::LinkedList() { head = NULL; } LinkedList::~LinkedList() { Node* cur = head, * tmp; while (cur != NULL) { tmp = cur->next; delete cur; cur = tmp; } } void LinkedList::add(char ch) { Node* cur = head,...
Deleting multiples of a given integer from a linked list: #include <stdio.h> #include <stdlib.h> #include <assert.h> #define MAX 10000 typedef struct node_tag { int v; // data struct node_tag * next; // A pointer to this type of struct } node; // Define a type. Easier to use. node * create_node(int v) { node * p = malloc(sizeof(node)); // Allocate memory assert(p != NULL); // you can be nicer // Set the value in the node. p->v = v; p->next...
CODE IN C++ Given: typedef char ItemType; // a struct type named NodeType that includes a ItemType and pointer // (to a NodeType) field struct NodeType { ItemType value; NodeType * next; }; bool Delete (NodeType * & firstPtr, ItemType value) { NodeType * prev, * cur; cur = Search (firstPtr, value, prev); if (cur==NULL) return false; else { // remove cur node from the linked list if (prev!=NULL) { //not the first one prev->next = cur->next;...
C PROGRAMMING #include <stdio.h> #include <stdlib.h> struct nodet { int data; struct nodet *link; }; struct nodet *makeAnode(int val) { struct nodet *box; box = malloc(sizeof(struct nodet) ); box->data = val; box->link = NULL; return box; } void printList(struct nodet *L) { struct nodet = *mov; mov = L; while(mov != NULL) { printf("%d ", mov->data); mov = mov->link; } printf("\n"); } // THIS SHOULD COUNT HOW MANY ITEMS (NODES) ARE IN THE LIST. int listLen(struct nodet **L) { int...
Your task is to complete the following function/functions: 1. Given a position in the linked list, delete the node at that position.(Silver problem - Mandatory ) 2. Print the sum of all negative elements in the linked list.(Gold problem) If you want, you can refer to the the previous recitation manual (which was on Linked Lists) to implement node deletion. #include <iostream> using namespace std; //----------- Define Node --------------------------------------------------- struct Node{ int key; Node *next; }; //----------- Define Linked List...