Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only the following functions are allowed to use in the application: struct listCDT { listElementT h; listADT t; }; typedef struct listCDT *listADT; typedef int

image text in transcribed Only the following functions are allowed to use in the application:

struct listCDT { listElementT h; listADT t; };

typedef struct listCDT *listADT; typedef int listElementT;

listADT EmptyList() { return((listADT)NULL); }

listADT Cons(listElementT h1, listADT t1) { listADT list = (listADT) malloc(sizeof(*list)); list->h = h1; list->t = t1; return (list); }

listElementT Head(listADT list) { if (ListIsEmpty(list)) exit(EXIT_FAILURE); return (list->h); }

listADT Tail(listADT list) { if (ListIsEmpty(list)) exit(EXIT_FAILURE); return (list->t); }

int ListIsEmpty(listADT list) { return (list == NULL); }

1. Write the following function that makes use of the listADT of list of integers: listADT moveMinToHead(listADT); which moves the minimum element in the list to the head of the list if the argument list is nonempty, or returns an empty list otherwise. For examples, moveMinToHead([]) = [] moveMinToHead([3,4,8,2,4]) = [2,3,4,8,4] moveMinToHead([3,5]) = [3,5] moveMinToHead([7]) = [7] . a) Write this function as a recursive function. Hint: Call moveMinToHead with the tail as the argument. b) Write this function as a nonrecursive function. 1. Write the following function that makes use of the listADT of list of integers: listADT moveMinToHead(listADT); which moves the minimum element in the list to the head of the list if the argument list is nonempty, or returns an empty list otherwise. For examples, moveMinToHead([]) = [] moveMinToHead([3,4,8,2,4]) = [2,3,4,8,4] moveMinToHead([3,5]) = [3,5] moveMinToHead([7]) = [7] . a) Write this function as a recursive function. Hint: Call moveMinToHead with the tail as the argument. b) Write this function as a nonrecursive function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

Students also viewed these Databases questions

Question

model flow of liquid in python code correctly

Answered: 1 week ago

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago

Question

Understand the role of corporate design in communications.

Answered: 1 week ago