-
Notifications
You must be signed in to change notification settings - Fork 9
/
moreLinkedListFuncs.h
executable file
·53 lines (36 loc) · 1.74 KB
/
moreLinkedListFuncs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef MORELINKEDLISTFUNCS_H
#define MORELINKEDLISTFUNCS_H
#include "linkedList.h"
void addIntToEndOfList(LinkedList *list, int value);
void addIntToStartOfList(LinkedList *list, int value);
// list: ptr to a linked list of Node (each with int data, and Node * next)
// Return a pointer to node with the largest value.
// You may assume list has at least one element
// If more than one element has largest value,
// break tie by returning a pointer to the one the occurs
// earlier in the list, i.e. closer to the head
Node * pointerToMax(LinkedList *list);
// list: ptr to a linked list of Node (each with int data, and Node * next)
// Return a pointer to node with the smallest value.
// You may assume list has at least one element
// If more than one element has smallest value,
// break tie by returning a pointer to the one the occurs
// earlier in the list, i.e. closer to the head
Node * pointerToMin(LinkedList *list);
// list: ptr to a linked list of Node (each with int data, and Node * next)
// Return the largest value in the list.
// This value may be unique, or may occur more than once
// You may assume list has at least one element
int largestValue(LinkedList *list);
// list: ptr to a linked list of Node (each with int data, and Node * next)
// Return the smallest value in the list.
// This value may be unique, or may occur more than once
// You may assume list has at least one element
int smallestValue(LinkedList *list);
// list: ptr to a linked list of Node (each with int data, and Node * next)
// Return the sum of all values in the list.
// You may assume that list is not NULL
// However, the list may be empty (i.e. list->head may be NULL)
// in which case your code should return 0.
int sum(LinkedList * list);
#endif