SlideShare a Scribd company logo
Using the provided table interface table.h and the sample linked list code linkedList.c, complete
an implementation of the Table ADT. Make sure that you apply the concepts of design by
contract (DbC) to your implementation.
Once you have fully implemented the table, create a main.c file that implements a testing
framework for your table.
Your table implementation must ensure that values inserted are unique, and internally sorted
within a linked list.
table.h
linkedList.c
Solution
khsdg
#include
#include
typedef enum BOOL { false, true } bool;
// Linked list node definition
typedef struct Node node;
struct Node
{
int number;
node *next;
};
static node *top = NULL;
// used to track where we are for the list traversal methods
static node *traverseNode = NULL;
// "destroy" will deallocate all nodes in a linked list object
// and will set "top" to NULL.
void destroy()
{
node *curr = top;
node *temp = NULL;
while ( curr != NULL )
{
// flip order to see it blow up...
temp = curr;
curr = curr->next;
free( temp );
}
top = NULL;
}
// "build" will create an ordered linked list consisting
// of the first "size" even integers.
void build( int size )
{
node *newNode = NULL;
int i = 0;
// make sure we don't have a list yet
destroy();
for ( i=size ; i>0 ; i-- )
{
newNode = malloc( sizeof( node ) );
newNode->number = i*2;
newNode->next = top;
top = newNode;
}
}
// starts a list traversal by getting the data at top.
// returns false if top == NULL.
bool firstNode( int *item )
{
bool result = false;
if ( top )
{
*item = top->number;
traverseNode = top->next;
result = true;
}
return result;
}
// gets the data at the current traversal node and increments the traversal.
// returns false if we're at the end of the list.
bool nextNode( int *item )
{
bool result = false;
if ( traverseNode )
{
*item = traverseNode->number;
traverseNode = traverseNode->next;
result = true;
}
return result;
}
// "print" will output an object's entire linked list
// to the standard output device -- one "number" per line.
void print()
{
int value;
if ( firstNode( &value ) )
{
do
{
printf( "%d ", value );
} while ( nextNode( &value ) );
}
}
int main( int argc, char *argv[] )
{
build( 10 );
print();
destroy();
build( 5 );
build( 20 );
print();
destroy();
return 0;
}
Ad

More Related Content

Similar to Using the provided table interface table.h and the sample linked lis.pdf (20)

TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
vasavim9
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
anton291
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
Sourav Gayen
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
rohit219406
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
arjunenterprises1978
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
clarkjanyce
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
fastechsrv
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
Masud Parvaze
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
RashidFaridChishti
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
KUNALHARCHANDANI1
 
Linked lists
Linked listsLinked lists
Linked lists
George Scott IV
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
anwarsadath111
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 
TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
vasavim9
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
anton291
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
Sourav Gayen
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
rohit219406
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
arjunenterprises1978
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
clarkjanyce
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
fastechsrv
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
RashidFaridChishti
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
KUNALHARCHANDANI1
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
anwarsadath111
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 

More from connellalykshamesb60 (20)

JAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
JAVA ProgrammingDesign a class Message that models an e-mail messa.pdfJAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
JAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
connellalykshamesb60
 
In which of the following structures are spores formed (Select all .pdf
In which of the following structures are spores formed (Select all .pdfIn which of the following structures are spores formed (Select all .pdf
In which of the following structures are spores formed (Select all .pdf
connellalykshamesb60
 
How does Windows managestore user names and passwords How does it .pdf
How does Windows managestore user names and passwords How does it .pdfHow does Windows managestore user names and passwords How does it .pdf
How does Windows managestore user names and passwords How does it .pdf
connellalykshamesb60
 
How to use class set a function(double money(); receive a number and .pdf
How to use class set a function(double money(); receive a number and .pdfHow to use class set a function(double money(); receive a number and .pdf
How to use class set a function(double money(); receive a number and .pdf
connellalykshamesb60
 
For each of the following descriptions indicate which best describes.pdf
For each of the following descriptions indicate which best describes.pdfFor each of the following descriptions indicate which best describes.pdf
For each of the following descriptions indicate which best describes.pdf
connellalykshamesb60
 
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdf
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdfExplain how an Annelidian differs from a MolluscanSolutionMoll.pdf
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdf
connellalykshamesb60
 
DNA s composed of nucleotides that are joined together by covalent bo.pdf
DNA s composed of nucleotides that are joined together by covalent bo.pdfDNA s composed of nucleotides that are joined together by covalent bo.pdf
DNA s composed of nucleotides that are joined together by covalent bo.pdf
connellalykshamesb60
 
Discuss some of the challenges involved in ensuring that critical kn.pdf
Discuss some of the challenges involved in ensuring that critical kn.pdfDiscuss some of the challenges involved in ensuring that critical kn.pdf
Discuss some of the challenges involved in ensuring that critical kn.pdf
connellalykshamesb60
 
Biologically, the term is synonymous with [Choose the term race. refe.pdf
Biologically, the term is synonymous with [Choose the term race. refe.pdfBiologically, the term is synonymous with [Choose the term race. refe.pdf
Biologically, the term is synonymous with [Choose the term race. refe.pdf
connellalykshamesb60
 
Anyone good with linguistics Are the following headlines transitive.pdf
Anyone good with linguistics Are the following headlines transitive.pdfAnyone good with linguistics Are the following headlines transitive.pdf
Anyone good with linguistics Are the following headlines transitive.pdf
connellalykshamesb60
 
A mother and father both have normal karyotypes. The father is color .pdf
A mother and father both have normal karyotypes. The father is color .pdfA mother and father both have normal karyotypes. The father is color .pdf
A mother and father both have normal karyotypes. The father is color .pdf
connellalykshamesb60
 
A man has a condition where all of his gametes undergo nondisjunctio.pdf
A man has a condition where all of his gametes undergo nondisjunctio.pdfA man has a condition where all of his gametes undergo nondisjunctio.pdf
A man has a condition where all of his gametes undergo nondisjunctio.pdf
connellalykshamesb60
 
____ The pigment produced by S. marvel scenes would appear first on t.pdf
____ The pigment produced by S. marvel scenes would appear first on t.pdf____ The pigment produced by S. marvel scenes would appear first on t.pdf
____ The pigment produced by S. marvel scenes would appear first on t.pdf
connellalykshamesb60
 
Write the advantages of using JavaFX with compare to Swing and AWT..pdf
Write the advantages of using JavaFX with compare to Swing and AWT..pdfWrite the advantages of using JavaFX with compare to Swing and AWT..pdf
Write the advantages of using JavaFX with compare to Swing and AWT..pdf
connellalykshamesb60
 
Write a program in c++ that produces a bar chart showing the populat.pdf
Write a program in c++ that produces a bar chart showing the populat.pdfWrite a program in c++ that produces a bar chart showing the populat.pdf
Write a program in c++ that produces a bar chart showing the populat.pdf
connellalykshamesb60
 
Write a 2 page essay describing what life was like in the Great Depr.pdf
Write a 2 page essay describing what life was like in the Great Depr.pdfWrite a 2 page essay describing what life was like in the Great Depr.pdf
Write a 2 page essay describing what life was like in the Great Depr.pdf
connellalykshamesb60
 
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdfWhy do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
connellalykshamesb60
 
Why Computer System Management is so critical for the companies (50.pdf
Why Computer System Management is so critical for the companies (50.pdfWhy Computer System Management is so critical for the companies (50.pdf
Why Computer System Management is so critical for the companies (50.pdf
connellalykshamesb60
 
Which of the following statements is not true about facilitated diff.pdf
Which of the following statements is not true about facilitated diff.pdfWhich of the following statements is not true about facilitated diff.pdf
Which of the following statements is not true about facilitated diff.pdf
connellalykshamesb60
 
Which is not a hypothesis for the origin of virusesThey originated .pdf
Which is not a hypothesis for the origin of virusesThey originated .pdfWhich is not a hypothesis for the origin of virusesThey originated .pdf
Which is not a hypothesis for the origin of virusesThey originated .pdf
connellalykshamesb60
 
JAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
JAVA ProgrammingDesign a class Message that models an e-mail messa.pdfJAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
JAVA ProgrammingDesign a class Message that models an e-mail messa.pdf
connellalykshamesb60
 
In which of the following structures are spores formed (Select all .pdf
In which of the following structures are spores formed (Select all .pdfIn which of the following structures are spores formed (Select all .pdf
In which of the following structures are spores formed (Select all .pdf
connellalykshamesb60
 
How does Windows managestore user names and passwords How does it .pdf
How does Windows managestore user names and passwords How does it .pdfHow does Windows managestore user names and passwords How does it .pdf
How does Windows managestore user names and passwords How does it .pdf
connellalykshamesb60
 
How to use class set a function(double money(); receive a number and .pdf
How to use class set a function(double money(); receive a number and .pdfHow to use class set a function(double money(); receive a number and .pdf
How to use class set a function(double money(); receive a number and .pdf
connellalykshamesb60
 
For each of the following descriptions indicate which best describes.pdf
For each of the following descriptions indicate which best describes.pdfFor each of the following descriptions indicate which best describes.pdf
For each of the following descriptions indicate which best describes.pdf
connellalykshamesb60
 
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdf
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdfExplain how an Annelidian differs from a MolluscanSolutionMoll.pdf
Explain how an Annelidian differs from a MolluscanSolutionMoll.pdf
connellalykshamesb60
 
DNA s composed of nucleotides that are joined together by covalent bo.pdf
DNA s composed of nucleotides that are joined together by covalent bo.pdfDNA s composed of nucleotides that are joined together by covalent bo.pdf
DNA s composed of nucleotides that are joined together by covalent bo.pdf
connellalykshamesb60
 
Discuss some of the challenges involved in ensuring that critical kn.pdf
Discuss some of the challenges involved in ensuring that critical kn.pdfDiscuss some of the challenges involved in ensuring that critical kn.pdf
Discuss some of the challenges involved in ensuring that critical kn.pdf
connellalykshamesb60
 
Biologically, the term is synonymous with [Choose the term race. refe.pdf
Biologically, the term is synonymous with [Choose the term race. refe.pdfBiologically, the term is synonymous with [Choose the term race. refe.pdf
Biologically, the term is synonymous with [Choose the term race. refe.pdf
connellalykshamesb60
 
Anyone good with linguistics Are the following headlines transitive.pdf
Anyone good with linguistics Are the following headlines transitive.pdfAnyone good with linguistics Are the following headlines transitive.pdf
Anyone good with linguistics Are the following headlines transitive.pdf
connellalykshamesb60
 
A mother and father both have normal karyotypes. The father is color .pdf
A mother and father both have normal karyotypes. The father is color .pdfA mother and father both have normal karyotypes. The father is color .pdf
A mother and father both have normal karyotypes. The father is color .pdf
connellalykshamesb60
 
A man has a condition where all of his gametes undergo nondisjunctio.pdf
A man has a condition where all of his gametes undergo nondisjunctio.pdfA man has a condition where all of his gametes undergo nondisjunctio.pdf
A man has a condition where all of his gametes undergo nondisjunctio.pdf
connellalykshamesb60
 
____ The pigment produced by S. marvel scenes would appear first on t.pdf
____ The pigment produced by S. marvel scenes would appear first on t.pdf____ The pigment produced by S. marvel scenes would appear first on t.pdf
____ The pigment produced by S. marvel scenes would appear first on t.pdf
connellalykshamesb60
 
Write the advantages of using JavaFX with compare to Swing and AWT..pdf
Write the advantages of using JavaFX with compare to Swing and AWT..pdfWrite the advantages of using JavaFX with compare to Swing and AWT..pdf
Write the advantages of using JavaFX with compare to Swing and AWT..pdf
connellalykshamesb60
 
Write a program in c++ that produces a bar chart showing the populat.pdf
Write a program in c++ that produces a bar chart showing the populat.pdfWrite a program in c++ that produces a bar chart showing the populat.pdf
Write a program in c++ that produces a bar chart showing the populat.pdf
connellalykshamesb60
 
Write a 2 page essay describing what life was like in the Great Depr.pdf
Write a 2 page essay describing what life was like in the Great Depr.pdfWrite a 2 page essay describing what life was like in the Great Depr.pdf
Write a 2 page essay describing what life was like in the Great Depr.pdf
connellalykshamesb60
 
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdfWhy do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
Why do silver nanoparticles of 10 nanometers in diameter have lower m.pdf
connellalykshamesb60
 
Why Computer System Management is so critical for the companies (50.pdf
Why Computer System Management is so critical for the companies (50.pdfWhy Computer System Management is so critical for the companies (50.pdf
Why Computer System Management is so critical for the companies (50.pdf
connellalykshamesb60
 
Which of the following statements is not true about facilitated diff.pdf
Which of the following statements is not true about facilitated diff.pdfWhich of the following statements is not true about facilitated diff.pdf
Which of the following statements is not true about facilitated diff.pdf
connellalykshamesb60
 
Which is not a hypothesis for the origin of virusesThey originated .pdf
Which is not a hypothesis for the origin of virusesThey originated .pdfWhich is not a hypothesis for the origin of virusesThey originated .pdf
Which is not a hypothesis for the origin of virusesThey originated .pdf
connellalykshamesb60
 
Ad

Recently uploaded (20)

How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Ad

Using the provided table interface table.h and the sample linked lis.pdf

  • 1. Using the provided table interface table.h and the sample linked list code linkedList.c, complete an implementation of the Table ADT. Make sure that you apply the concepts of design by contract (DbC) to your implementation. Once you have fully implemented the table, create a main.c file that implements a testing framework for your table. Your table implementation must ensure that values inserted are unique, and internally sorted within a linked list. table.h linkedList.c Solution khsdg #include #include typedef enum BOOL { false, true } bool; // Linked list node definition typedef struct Node node; struct Node { int number; node *next; }; static node *top = NULL; // used to track where we are for the list traversal methods static node *traverseNode = NULL; // "destroy" will deallocate all nodes in a linked list object // and will set "top" to NULL. void destroy() { node *curr = top; node *temp = NULL; while ( curr != NULL ) {
  • 2. // flip order to see it blow up... temp = curr; curr = curr->next; free( temp ); } top = NULL; } // "build" will create an ordered linked list consisting // of the first "size" even integers. void build( int size ) { node *newNode = NULL; int i = 0; // make sure we don't have a list yet destroy(); for ( i=size ; i>0 ; i-- ) { newNode = malloc( sizeof( node ) ); newNode->number = i*2; newNode->next = top; top = newNode; } } // starts a list traversal by getting the data at top. // returns false if top == NULL. bool firstNode( int *item ) { bool result = false; if ( top ) { *item = top->number; traverseNode = top->next; result = true; } return result; }
  • 3. // gets the data at the current traversal node and increments the traversal. // returns false if we're at the end of the list. bool nextNode( int *item ) { bool result = false; if ( traverseNode ) { *item = traverseNode->number; traverseNode = traverseNode->next; result = true; } return result; } // "print" will output an object's entire linked list // to the standard output device -- one "number" per line. void print() { int value; if ( firstNode( &value ) ) { do { printf( "%d ", value ); } while ( nextNode( &value ) ); } } int main( int argc, char *argv[] ) { build( 10 ); print(); destroy(); build( 5 ); build( 20 ); print(); destroy(); return 0;
  • 4. }