+1 (208) 254-6996 [email protected]
  

Follow the instructions I attached in the file

hw5/instructions.pdf

__MACOSX/hw5/._instructions.pdf

hw5/.DS_Store

__MACOSX/hw5/._.DS_Store

hw5/BonusHW_export (1).zip

type.h

/* type.h Defines the type to be stored in the data structure. These macros are for convenience to avoid having to search and replace/dup code when you want to build a structure of doubles as opposed to ints for example. */ #ifndef __TYPE_H #define __TYPE_H #define TASK_DESC_SIZE 128 struct Task { char description[TASK_DESC_SIZE]; /* description of the task */ int priority; /* task priority */ }; typedef struct Task Task; # ifndef TYPE # define TYPE Task # define TYPE_SIZE sizeof(Task) # endif /* function used to compare two TYPE values to each other */ int compare(TYPE left, TYPE right); #endif

Don't use plagiarized sources. Get Your Custom Essay on
AVL Tree And Heap(C Language)(Data Structure)
Just from $13/Page
Order Essay

toDoList.h

#ifndef __TODOLIST_H #define __TODOLIST_H #include “dynArray.h” TYPE createTask (int priority, char *desc); void saveList(DynArr *heap, FILE *filePtr); void loadList(DynArr *heap, FILE *filePtr); void printList(DynArr *heap); #endif

toDoList.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” /* Create a task from the description and the priority param: priority priority of the task param: desc pointer to the description string pre: none post: none ret: a task with description and priority */ TYPE createTask (int priority, char *desc) { TYPE newTask; newTask.priority = priority; strcpy(newTask.description, desc); return newTask; } /* Save the list to a file param: heap pointer to the list param: filePtr pointer to the file to which the list is saved pre: The list is not empty post: The list is saved to the file in tab-delimited format. Each line in the file stores a task, starting with the task priority, followed by a tab character (\t), and the task description. The tasks are not necessarily stored in the file in priority order. */ void saveList(DynArr *heap, FILE *filePtr) { /* FIX ME */ } /* Load the list from a file param: heap pointer to the list param: filePtr pointer to the file pre: none post: The tasks are retrieved from the file and are added to the list. Refer to the saveList() function for the format of tasks in the file */ void loadList(DynArr *heap, FILE *filePtr) { /* FIX ME */ } /* Print the list param: heap pointer to the list pre: the list is not empty post: The tasks from the list are printed out in priority order. The tasks are not removed from the list. */ void printList(DynArr *heap) { /* FIX ME */ } /* Compare two tasks by priority param: left first task param: right second task pre: none post: none ret: -1 if priority of left < priority of right 1 if priority of left > priority of right 0 if priority of left = priority of right */ int compare(TYPE left, TYPE right) { if (left.priority < right.priority) return -1; else if (left.priority > right.priority) return 1; else return 0; }

todo.txt

0 take a nap 1 study heap-based priority queue 101 review trees for Midterm 2 3 do assignment 7

program_demo.txt

flip ~/cs261/as5/todo_list 605% ./prog ** TO-DO LIST APPLICATION ** Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: do assignment 5 Please enter the task priority (0-999): 3 The task ‘do assignment 5’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: study heap-based priority queue Please enter the task priority (0-999): 1 The task ‘study heap-based priority queue’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: review trees for Midterm 2 Please enter the task priority (0-999): 101 The task ‘review trees for Midterm 2’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your first task is: study heap-based priority queue Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: take a nap Please enter the task priority (0-999): 0 The task ‘take a nap’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program s Please enter the filename: todo.txt The list has been saved into the file successfully. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program e Bye! ============ flip ~/cs261/as5/todo_list 613% ./prog ** TO-DO LIST APPLICATION ** Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program l Please enter the filename: todo.txt The list has been loaded from file successfully. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your first task is: take a nap Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘take a nap’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program p study heap-based priority queue do assignment 5 review trees for Midterm 2 Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘study heap-based priority queue’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘do assignment 5’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘review trees for Midterm 2’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program e Bye!

Makefile

default: prog dynArray.o: dynArray.c dynArray.h type.h gcc -Wall -ansi -c dynArray.c toDoList.o: toDoList.c toDoList.h type.h gcc -Wall -ansi -c toDoList.c prog: dynArray.o toDoList.o main.c gcc -Wall -ansi -o prog dynArray.o toDoList.o main.c clean: rm dynArray.o rm toDoList.o cleanall: clean rm prog

main2.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” int main2 (int argc, const char * argv[]) { TYPE task1, task2, task3, task4, task5, task6, task7, task8, task9, task10; DynArr mainList; int i; initDynArr(&mainList, 10); /* create tasks */ task1 = createTask(9, “task 1”); task2 = createTask(3, “task 2”); task3 = createTask(2, “task 3”); task4 = createTask(4, “task 4”); task5 = createTask(5, “task 5”); task6 = createTask(7, “task 6”); task7 = createTask(8, “task 7”); task8 = createTask(6, “task 8”); task9 = createTask(1, “task 9”); task10 = createTask(0, “task 10”); /* add tasks to the dynamic array */ addDynArr(&mainList, task1); addDynArr(&mainList, task2); addDynArr(&mainList, task3); addDynArr(&mainList, task4); addDynArr(&mainList, task5); addDynArr(&mainList, task6); addDynArr(&mainList, task7); addDynArr(&mainList, task8); addDynArr(&mainList, task9); addDynArr(&mainList, task10); /* sort tasks */ sortHeap(&mainList); /* print sorted tasks from the dynamic array */ for (i = 0; i < mainList.size; i++) { printf(“%d\n”, mainList.data[i].priority); } return 0; }

main.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” int main (int argc, const char * argv[]) { TYPE newTask, firstTask; char desc[TASK_DESC_SIZE], filename[50], *nlptr; int priority; char cmd = ‘ ‘; FILE *filePointer; DynArr mainList; initDynArr(&mainList, 10); printf(“\n\n** TO-DO LIST APPLICATION **\n\n”); do { printf(“Press:\n” “‘l’ to load to-do list from a file\n” “‘s’ to save to-do list to a file\n” “‘a’ to add a new task\n” “‘g’ to get the first task\n” “‘r’ to remove the first task\n” “‘p’ to print the list\n” “‘e’ to exit the program\n” ); /* get input command (from the keyboard) */ cmd = getchar(); /* clear the trailing newline character */ while (getchar() != ‘\n’); switch (cmd) { case ‘a’: /* add new task */ printf(“Please enter the task description: “); /* get task description from user input (from keyboard) */ if (fgets(desc, sizeof(desc), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(desc, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* get task priority from user input (from keyboard) */ do { printf(“Please enter the task priority (0-999): “); scanf(“%d”, &priority); } while(!(priority >= 0 && priority <= 999)); /* clear the trailing newline character */ while (getchar() != ‘\n’); /* create task and add the task to the heap */ newTask = createTask(priority, desc); addHeap(&mainList, newTask); printf(“The task ‘%s’ has been added to your to-do list.\n\n”, desc); break; case ‘g’: /* get the first task */ if (sizeDynArr(&mainList) > 0) { firstTask = getMinHeap(&mainList); printf(“Your first task is: %s\n\n”, firstTask.description); } else printf(“Your to-do list is empty!\n\n”); break; case ‘r’: /* remove the first task */ if (sizeDynArr(&mainList) > 0) { firstTask = getMinHeap(&mainList); removeMinHeap(&mainList); printf(“Your first task ‘%s’ has been removed from the list.\n\n”, firstTask.description); } else printf(“Your to-do list is empty!\n\n”); break; case ‘p’: /* print the list */ if (sizeDynArr(&mainList) > 0) { printList(&mainList); } else printf(“Your to-do list is empty!\n\n”); break; case ‘s’: /* save the list to file */ if (sizeDynArr(&mainList) > 0) { /* get filename from user input (from keyboard) */ printf(“Please enter the filename: “); if (fgets(filename, sizeof(filename), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(filename, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* open the file */ filePointer = fopen(filename, “w”); if (filePointer == NULL) { fprintf(stderr, “Cannot open %s\n”, filename); break; } /* save the list to the file */ saveList(&mainList, filePointer); /* close the file */ fclose(filePointer); printf(“The list has been saved into the file successfully.\n\n”); } else printf(“Your to-do list is empty!\n\n”); break; case ‘l’: /* load the list from the file */ printf(“Please enter the filename: “); /* get filename from user input (from keyboard) */ if (fgets(filename, sizeof(filename), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(filename, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* open the file */ filePointer = fopen(filename, “r”); if (filePointer == NULL) { fprintf(stderr, “Cannot open %s\n”, filename); break; } /* load the list from the file */ loadList(&mainList, filePointer); /* close the file */ fclose(filePointer); printf(“The list has been loaded from file successfully.\n\n”); break; case ‘e’: /* exit the program */ printf(“Bye!\n\n”); break; default: printf(“What is your command anyway?\n\n” ); break; } } while(cmd != ‘e’); /* free the list */ freeDynArr(&mainList); return 0; }

dynArray.h

/* dynArray.h : Dynamic Array implementation. */ #ifndef DYNAMIC_ARRAY_INCLUDED #define DYNAMIC_ARRAY_INCLUDED 1 #include “type.h” struct DynArr { TYPE *data; /* pointer to the data array */ int size; /* Number of elements in the array */ int capacity; /* capacity ofthe array */ }; 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); void _dynArrSetCapacity(DynArr *v, int newCap); int sizeDynArr(DynArr *v); void addDynArr(DynArr *v, TYPE val); TYPE getDynArr(DynArr *v, int pos); void putDynArr(DynArr *v, int pos, TYPE val); void swapDynArr(DynArr *v, int i, int j); void removeAtDynArr(DynArr *v, int idx); int isEmptyDynArr(DynArr *v); void copyDynArr(DynArr *source, DynArr *destination); /* Heap-based Priority Queue Interface */ TYPE getMinHeap(DynArr *heap); void addHeap(DynArr *heap, TYPE node); void removeMinHeap(DynArr *heap); void sortHeap(DynArr *heap); #endif

dynArray.c

/* dynArray.c: Dynamic Array implementation. */ #include <assert.h> #include <stdlib.h> #include “dynArray.h” /* ************************************************************************ Dynamic Array Functions ************************************************************************ */ /* Initialize (including allocation of data array) dynamic array. param: v pointer to the dynamic array param: cap capacity of the dynamic array pre: v is not null post: internal data array can hold cap elements post: v->data is not null */ void initDynArr(DynArr *v, int capacity) { v->data = (TYPE *) malloc(sizeof(TYPE) * capacity); assert(v->data != 0); v->size = 0; v->capacity = capacity; } /* Allocate and initialize dynamic array. param: cap desired capacity for the dyn array pre: none post: none ret: a non-null pointer to a dynArr of cap capacity and 0 elements in it. */ DynArr* newDynArr(int cap) { DynArr *r = (DynArr *)malloc(sizeof( DynArr)); assert(r != 0); initDynArr(r,cap); return r; } /* Deallocate data array in dynamic array. param: v pointer to the dynamic array pre: none post: d.data points to null post: size and capacity are 0 post: the memory used by v->data is freed */ void freeDynArr(DynArr *v) { if(v->data != 0) { free(v->data); /* free the space on the heap */ v->data = 0; /* make it point to null */ } v->size = 0; v->capacity = 0; } /* Deallocate data array and the dynamic array ure. param: v pointer to the dynamic array pre: none post: the memory used by v->data is freed post: the memory used by d is freed */ void deleteDynArr(DynArr *v) { freeDynArr(v); free(v); } /* Resizes the underlying array to be the size cap param: v pointer to the dynamic array param: cap the new desired capacity pre: v is not null post: v has capacity newCap */ void _dynArrSetCapacity(DynArr *v, int newCap) { int i; /* Create a new underlying array */ TYPE *newData = (TYPE*)malloc(sizeof(TYPE)*newCap); assert(newData != 0); /* copy elements to new data array */ for(i = 0; i < v->size; i++) newData[i] = v->data[i]; /* Delete the old underlying array */ freeDynArr(v); /* update capacity and size and data */ v->data = newData; v->capacity = newCap; v->size = i; } /* Get the size of the dynamic array param: v pointer to the dynamic array pre: v is not null post: none ret: the size of the dynamic array */ int sizeDynArr(DynArr *v) { return v->size; } /* Adds an element to the end of the dynamic array param: v pointer to the dynamic array param: val the value to add to the end of the dynamic array pre: the dynArry is not null post: size increases by 1 post: if reached capacity, capacity is doubled post: val is in the last utilized position in the array */ void addDynArr(DynArr *v, TYPE val) { /* Check to see if a resize is necessary */ if(v->size >= v->capacity) _dynArrSetCapacity(v, 2 * v->capacity); v->data[v->size] = val; v->size++; } /* Get an element from the dynamic array from a specified position param: v pointer to the dynamic array param: pos integer index to get the element from pre: v is not null pre: v is not empty pre: pos < size of the dyn array and >= 0 post: no changes to the dyn Array ret: value stored at index pos */ TYPE getDynArr(DynArr *v, int pos) { assert(pos < v->size); assert(pos >= 0); return v->data[pos]; } /* Put an item into the dynamic array at the specified location, overwriting the element that was there param: v pointer to the dynamic array param: pos the index to put the value into param: val the value to insert pre: v is not null pre: v is not empty pre: pos >= 0 and pos < size of the array post: index pos contains new value, val */ void putDynArr(DynArr *v, int pos, TYPE val) { assert(pos < v->size); v->data[pos] = val; } /* Swap two specified elements in the dynamic array param: v pointer to the dynamic array param: i,j the elements to be swapped pre: v is not null pre: v is not empty pre: i, j >= 0 and i,j < size of the dynamic array post: index i now holds the value at j and index j now holds the value at i */ void swapDynArr(DynArr *v, int i, int j) { TYPE temp; assert(i < v->size); assert(j < v->size); temp = v->data[i]; v->data[i] = v->data[j]; v->data[j] = temp; } /* Remove the element at the specified location from the array, shifts other elements back one to fill the gap param: v pointer to the dynamic array param: idx location of element to remove pre: v is not null pre: v is not empty pre: idx < size and idx >= 0 post: the element at idx is removed post: the elements past idx are moved back one */ void removeAtDynArr(DynArr *v, int idx) { int i; for(i = idx; i < v->size-1; ++i) v->data[i] = v->data[i+1]; if(idx >= 0 && idx < v->size) –v->size; } /* Copy elements from a dynamic array to another dynamic array param: source pointer to the source dynamic array param: destination pointer to the destination dynamic array pre: s is not null and s is not empty post: destination is initialized post: the elements from source are copied to destination */ void copyDynArr(DynArr *source, DynArr *destination) { int i; assert(source->size > 0); initDynArr(destination, source->capacity); /* copy elements to destination array */ for(i = 0; i < source->size; i++) destination->data[i] = source->data[i]; destination->size = source->size; } /* ************************************************************************ Heap-based Priority Queue Implementation ************************************************************************ */ /* internal function prototypes */ int _smallerIndexHeap(DynArr *heap, int i, int j); void _adjustHeap(DynArr *heap, int max, int pos); /* Get the index of the smaller node between two nodes in a heap param: heap pointer to the heap param: i index of one node param: j index of other node pre: i < size and j < size ret: the index of the smaller node */ int _smallerIndexHeap(DynArr *heap, int i, int j) { assert(i < sizeDynArr(heap)); assert(j < sizeDynArr(heap)); if (compare(getDynArr(heap, i), getDynArr(heap, j)) == -1) return i; else return j; } /* Get the first node, which has the max priority (i.e., min value), from the heap param: heap pointer to the heap pre: heap is not empty ret: value of first node */ TYPE getMinHeap(DynArr *heap) { /* FIXME */ TYPE temp; return temp; } /* Add a node to the heap param: heap pointer to the heap param: node node to be added to the heap pre: heap is not null post: node is added to the heap */ void addHeap(DynArr *heap, TYPE node) { /* FIXME */ } /* Adjust heap to maintain heap property param: heap pointer to the heap param: max max index of the heap nodes in the dynamic array param: pos position index where the adjustment starts pre: none post: heap property is maintained for nodes from index pos to index max */ void _adjustHeap(DynArr *heap, int max, int pos) { /* FIXME */ } /* Remove the first node, which has the max priority (i.e., min value), from the heap param: heap pointer to the heap pre: heap is not empty post: the first node is removed from the heap */ void removeMinHeap(DynArr *heap) { /* FIXME */ } /* builds a heap from an arbitrary dynArray param: v dynamicArray pre: v is not empty post: v is a proper heap */ void _buildHeap(DynArr *heap) { /* FIXME */ } /* In-place sort of the heap param: heap pointer to the heap pre: heap is not empty post: the dynArr is in reverse sorted order */ void sortHeap(DynArr *heap) { /*FIXME*/ }

__MACOSX/hw5/._BonusHW_export (1).zip

__MACOSX/hw5/._BonusHW_export

hw5/BonusHW_export /type.h

/* type.h Defines the type to be stored in the data structure. These macros are for convenience to avoid having to search and replace/dup code when you want to build a structure of doubles as opposed to ints for example. */ #ifndef __TYPE_H #define __TYPE_H #define TASK_DESC_SIZE 128 struct Task { char description[TASK_DESC_SIZE]; /* description of the task */ int priority; /* task priority */ }; typedef struct Task Task; # ifndef TYPE # define TYPE Task # define TYPE_SIZE sizeof(Task) # endif /* function used to compare two TYPE values to each other */ int compare(TYPE left, TYPE right); #endif

__MACOSX/hw5/BonusHW_export /._type.h

hw5/BonusHW_export /toDoList.h

#ifndef __TODOLIST_H #define __TODOLIST_H #include “dynArray.h” TYPE createTask (int priority, char *desc); void saveList(DynArr *heap, FILE *filePtr); void loadList(DynArr *heap, FILE *filePtr); void printList(DynArr *heap); #endif

__MACOSX/hw5/BonusHW_export /._toDoList.h

hw5/BonusHW_export /program_demo.txt

flip ~/cs261/as5/todo_list 605% ./prog ** TO-DO LIST APPLICATION ** Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: do assignment 5 Please enter the task priority (0-999): 3 The task ‘do assignment 5’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: study heap-based priority queue Please enter the task priority (0-999): 1 The task ‘study heap-based priority queue’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: review trees for Midterm 2 Please enter the task priority (0-999): 101 The task ‘review trees for Midterm 2’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your first task is: study heap-based priority queue Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program a Please enter the task description: take a nap Please enter the task priority (0-999): 0 The task ‘take a nap’ has been added to your to-do list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program s Please enter the filename: todo.txt The list has been saved into the file successfully. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program e Bye! ============ flip ~/cs261/as5/todo_list 613% ./prog ** TO-DO LIST APPLICATION ** Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program l Please enter the filename: todo.txt The list has been loaded from file successfully. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program g Your first task is: take a nap Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘take a nap’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program p study heap-based priority queue do assignment 5 review trees for Midterm 2 Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘study heap-based priority queue’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘do assignment 5’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your first task ‘review trees for Midterm 2’ has been removed from the list. Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program r Your to-do list is empty! Press: ‘l’ to load to-do list from a file ‘s’ to save to-do list to a file ‘a’ to add a new task ‘g’ to get the first task ‘r’ to remove the first task ‘p’ to print the list ‘e’ to exit the program e Bye!

__MACOSX/hw5/BonusHW_export /._program_demo.txt

hw5/BonusHW_export /todo.txt

0 take a nap 1 study heap-based priority queue 101 review trees for Midterm 2 3 do assignment 7

__MACOSX/hw5/BonusHW_export /._todo.txt

hw5/BonusHW_export /dynArray.c

/* dynArray.c: Dynamic Array implementation. */ #include <assert.h> #include <stdlib.h> #include “dynArray.h” /* ************************************************************************ Dynamic Array Functions ************************************************************************ */ /* Initialize (including allocation of data array) dynamic array. param: v pointer to the dynamic array param: cap capacity of the dynamic array pre: v is not null post: internal data array can hold cap elements post: v->data is not null */ void initDynArr(DynArr *v, int capacity) { v->data = (TYPE *) malloc(sizeof(TYPE) * capacity); assert(v->data != 0); v->size = 0; v->capacity = capacity; } /* Allocate and initialize dynamic array. param: cap desired capacity for the dyn array pre: none post: none ret: a non-null pointer to a dynArr of cap capacity and 0 elements in it. */ DynArr* newDynArr(int cap) { DynArr *r = (DynArr *)malloc(sizeof( DynArr)); assert(r != 0); initDynArr(r,cap); return r; } /* Deallocate data array in dynamic array. param: v pointer to the dynamic array pre: none post: d.data points to null post: size and capacity are 0 post: the memory used by v->data is freed */ void freeDynArr(DynArr *v) { if(v->data != 0) { free(v->data); /* free the space on the heap */ v->data = 0; /* make it point to null */ } v->size = 0; v->capacity = 0; } /* Deallocate data array and the dynamic array ure. param: v pointer to the dynamic array pre: none post: the memory used by v->data is freed post: the memory used by d is freed */ void deleteDynArr(DynArr *v) { freeDynArr(v); free(v); } /* Resizes the underlying array to be the size cap param: v pointer to the dynamic array param: cap the new desired capacity pre: v is not null post: v has capacity newCap */ void _dynArrSetCapacity(DynArr *v, int newCap) { int i; /* Create a new underlying array */ TYPE *newData = (TYPE*)malloc(sizeof(TYPE)*newCap); assert(newData != 0); /* copy elements to new data array */ for(i = 0; i < v->size; i++) newData[i] = v->data[i]; /* Delete the old underlying array */ freeDynArr(v); /* update capacity and size and data */ v->data = newData; v->capacity = newCap; v->size = i; } /* Get the size of the dynamic array param: v pointer to the dynamic array pre: v is not null post: none ret: the size of the dynamic array */ int sizeDynArr(DynArr *v) { return v->size; } /* Adds an element to the end of the dynamic array param: v pointer to the dynamic array param: val the value to add to the end of the dynamic array pre: the dynArry is not null post: size increases by 1 post: if reached capacity, capacity is doubled post: val is in the last utilized position in the array */ void addDynArr(DynArr *v, TYPE val) { /* Check to see if a resize is necessary */ if(v->size >= v->capacity) _dynArrSetCapacity(v, 2 * v->capacity); v->data[v->size] = val; v->size++; } /* Get an element from the dynamic array from a specified position param: v pointer to the dynamic array param: pos integer index to get the element from pre: v is not null pre: v is not empty pre: pos < size of the dyn array and >= 0 post: no changes to the dyn Array ret: value stored at index pos */ TYPE getDynArr(DynArr *v, int pos) { assert(pos < v->size); assert(pos >= 0); return v->data[pos]; } /* Put an item into the dynamic array at the specified location, overwriting the element that was there param: v pointer to the dynamic array param: pos the index to put the value into param: val the value to insert pre: v is not null pre: v is not empty pre: pos >= 0 and pos < size of the array post: index pos contains new value, val */ void putDynArr(DynArr *v, int pos, TYPE val) { assert(pos < v->size); v->data[pos] = val; } /* Swap two specified elements in the dynamic array param: v pointer to the dynamic array param: i,j the elements to be swapped pre: v is not null pre: v is not empty pre: i, j >= 0 and i,j < size of the dynamic array post: index i now holds the value at j and index j now holds the value at i */ void swapDynArr(DynArr *v, int i, int j) { TYPE temp; assert(i < v->size); assert(j < v->size); temp = v->data[i]; v->data[i] = v->data[j]; v->data[j] = temp; } /* Remove the element at the specified location from the array, shifts other elements back one to fill the gap param: v pointer to the dynamic array param: idx location of element to remove pre: v is not null pre: v is not empty pre: idx < size and idx >= 0 post: the element at idx is removed post: the elements past idx are moved back one */ void removeAtDynArr(DynArr *v, int idx) { int i; for(i = idx; i < v->size-1; ++i) v->data[i] = v->data[i+1]; if(idx >= 0 && idx < v->size) –v->size; } /* Copy elements from a dynamic array to another dynamic array param: source pointer to the source dynamic array param: destination pointer to the destination dynamic array pre: s is not null and s is not empty post: destination is initialized post: the elements from source are copied to destination */ void copyDynArr(DynArr *source, DynArr *destination) { int i; assert(source->size > 0); initDynArr(destination, source->capacity); /* copy elements to destination array */ for(i = 0; i < source->size; i++) destination->data[i] = source->data[i]; destination->size = source->size; } /* ************************************************************************ Heap-based Priority Queue Implementation ************************************************************************ */ /* internal function prototypes */ int _smallerIndexHeap(DynArr *heap, int i, int j); void _adjustHeap(DynArr *heap, int max, int pos); /* Get the index of the smaller node between two nodes in a heap param: heap pointer to the heap param: i index of one node param: j index of other node pre: i < size and j < size ret: the index of the smaller node */ int _smallerIndexHeap(DynArr *heap, int i, int j) { assert(i < sizeDynArr(heap)); assert(j < sizeDynArr(heap)); if (compare(getDynArr(heap, i), getDynArr(heap, j)) == -1) return i; else return j; } /* Get the first node, which has the max priority (i.e., min value), from the heap param: heap pointer to the heap pre: heap is not empty ret: value of first node */ TYPE getMinHeap(DynArr *heap) { /* FIXME */ TYPE temp; return temp; } /* Add a node to the heap param: heap pointer to the heap param: node node to be added to the heap pre: heap is not null post: node is added to the heap */ void addHeap(DynArr *heap, TYPE node) { /* FIXME */ } /* Adjust heap to maintain heap property param: heap pointer to the heap param: max max index of the heap nodes in the dynamic array param: pos position index where the adjustment starts pre: none post: heap property is maintained for nodes from index pos to index max */ void _adjustHeap(DynArr *heap, int max, int pos) { /* FIXME */ } /* Remove the first node, which has the max priority (i.e., min value), from the heap param: heap pointer to the heap pre: heap is not empty post: the first node is removed from the heap */ void removeMinHeap(DynArr *heap) { /* FIXME */ } /* builds a heap from an arbitrary dynArray param: v dynamicArray pre: v is not empty post: v is a proper heap */ void _buildHeap(DynArr *heap) { /* FIXME */ } /* In-place sort of the heap param: heap pointer to the heap pre: heap is not empty post: the dynArr is in reverse sorted order */ void sortHeap(DynArr *heap) { /*FIXME*/ }

__MACOSX/hw5/BonusHW_export /._dynArray.c

hw5/BonusHW_export /Makefile

default: prog dynArray.o: dynArray.c dynArray.h type.h gcc -Wall -ansi -c dynArray.c toDoList.o: toDoList.c toDoList.h type.h gcc -Wall -ansi -c toDoList.c prog: dynArray.o toDoList.o main.c gcc -Wall -ansi -o prog dynArray.o toDoList.o main.c clean: rm dynArray.o rm toDoList.o cleanall: clean rm prog

__MACOSX/hw5/BonusHW_export /._Makefile

hw5/BonusHW_export /main2.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” int main2 (int argc, const char * argv[]) { TYPE task1, task2, task3, task4, task5, task6, task7, task8, task9, task10; DynArr mainList; int i; initDynArr(&mainList, 10); /* create tasks */ task1 = createTask(9, “task 1”); task2 = createTask(3, “task 2”); task3 = createTask(2, “task 3”); task4 = createTask(4, “task 4”); task5 = createTask(5, “task 5”); task6 = createTask(7, “task 6”); task7 = createTask(8, “task 7”); task8 = createTask(6, “task 8”); task9 = createTask(1, “task 9”); task10 = createTask(0, “task 10”); /* add tasks to the dynamic array */ addDynArr(&mainList, task1); addDynArr(&mainList, task2); addDynArr(&mainList, task3); addDynArr(&mainList, task4); addDynArr(&mainList, task5); addDynArr(&mainList, task6); addDynArr(&mainList, task7); addDynArr(&mainList, task8); addDynArr(&mainList, task9); addDynArr(&mainList, task10); /* sort tasks */ sortHeap(&mainList); /* print sorted tasks from the dynamic array */ for (i = 0; i < mainList.size; i++) { printf(“%d\n”, mainList.data[i].priority); } return 0; }

__MACOSX/hw5/BonusHW_export /._main2.c

hw5/BonusHW_export /main.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” int main (int argc, const char * argv[]) { TYPE newTask, firstTask; char desc[TASK_DESC_SIZE], filename[50], *nlptr; int priority; char cmd = ‘ ‘; FILE *filePointer; DynArr mainList; initDynArr(&mainList, 10); printf(“\n\n** TO-DO LIST APPLICATION **\n\n”); do { printf(“Press:\n” “‘l’ to load to-do list from a file\n” “‘s’ to save to-do list to a file\n” “‘a’ to add a new task\n” “‘g’ to get the first task\n” “‘r’ to remove the first task\n” “‘p’ to print the list\n” “‘e’ to exit the program\n” ); /* get input command (from the keyboard) */ cmd = getchar(); /* clear the trailing newline character */ while (getchar() != ‘\n’); switch (cmd) { case ‘a’: /* add new task */ printf(“Please enter the task description: “); /* get task description from user input (from keyboard) */ if (fgets(desc, sizeof(desc), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(desc, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* get task priority from user input (from keyboard) */ do { printf(“Please enter the task priority (0-999): “); scanf(“%d”, &priority); } while(!(priority >= 0 && priority <= 999)); /* clear the trailing newline character */ while (getchar() != ‘\n’); /* create task and add the task to the heap */ newTask = createTask(priority, desc); addHeap(&mainList, newTask); printf(“The task ‘%s’ has been added to your to-do list.\n\n”, desc); break; case ‘g’: /* get the first task */ if (sizeDynArr(&mainList) > 0) { firstTask = getMinHeap(&mainList); printf(“Your first task is: %s\n\n”, firstTask.description); } else printf(“Your to-do list is empty!\n\n”); break; case ‘r’: /* remove the first task */ if (sizeDynArr(&mainList) > 0) { firstTask = getMinHeap(&mainList); removeMinHeap(&mainList); printf(“Your first task ‘%s’ has been removed from the list.\n\n”, firstTask.description); } else printf(“Your to-do list is empty!\n\n”); break; case ‘p’: /* print the list */ if (sizeDynArr(&mainList) > 0) { printList(&mainList); } else printf(“Your to-do list is empty!\n\n”); break; case ‘s’: /* save the list to file */ if (sizeDynArr(&mainList) > 0) { /* get filename from user input (from keyboard) */ printf(“Please enter the filename: “); if (fgets(filename, sizeof(filename), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(filename, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* open the file */ filePointer = fopen(filename, “w”); if (filePointer == NULL) { fprintf(stderr, “Cannot open %s\n”, filename); break; } /* save the list to the file */ saveList(&mainList, filePointer); /* close the file */ fclose(filePointer); printf(“The list has been saved into the file successfully.\n\n”); } else printf(“Your to-do list is empty!\n\n”); break; case ‘l’: /* load the list from the file */ printf(“Please enter the filename: “); /* get filename from user input (from keyboard) */ if (fgets(filename, sizeof(filename), stdin) != NULL) { /* remove trailing newline character */ nlptr = strchr(filename, ‘\n’); if (nlptr) *nlptr = ‘\0’; } /* open the file */ filePointer = fopen(filename, “r”); if (filePointer == NULL) { fprintf(stderr, “Cannot open %s\n”, filename); break; } /* load the list from the file */ loadList(&mainList, filePointer); /* close the file */ fclose(filePointer); printf(“The list has been loaded from file successfully.\n\n”); break; case ‘e’: /* exit the program */ printf(“Bye!\n\n”); break; default: printf(“What is your command anyway?\n\n” ); break; } } while(cmd != ‘e’); /* free the list */ freeDynArr(&mainList); return 0; }

__MACOSX/hw5/BonusHW_export /._main.c

hw5/BonusHW_export /dynArray.h

/* dynArray.h : Dynamic Array implementation. */ #ifndef DYNAMIC_ARRAY_INCLUDED #define DYNAMIC_ARRAY_INCLUDED 1 #include “type.h” struct DynArr { TYPE *data; /* pointer to the data array */ int size; /* Number of elements in the array */ int capacity; /* capacity ofthe array */ }; 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); void _dynArrSetCapacity(DynArr *v, int newCap); int sizeDynArr(DynArr *v); void addDynArr(DynArr *v, TYPE val); TYPE getDynArr(DynArr *v, int pos); void putDynArr(DynArr *v, int pos, TYPE val); void swapDynArr(DynArr *v, int i, int j); void removeAtDynArr(DynArr *v, int idx); int isEmptyDynArr(DynArr *v); void copyDynArr(DynArr *source, DynArr *destination); /* Heap-based Priority Queue Interface */ TYPE getMinHeap(DynArr *heap); void addHeap(DynArr *heap, TYPE node); void removeMinHeap(DynArr *heap); void sortHeap(DynArr *heap); #endif

__MACOSX/hw5/BonusHW_export /._dynArray.h

hw5/BonusHW_export /toDoList.c

#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include “toDoList.h” /* Create a task from the description and the priority param: priority priority of the task param: desc pointer to the description string pre: none post: none ret: a task with description and priority */ TYPE createTask (int priority, char *desc) { TYPE newTask; newTask.priority = priority; strcpy(newTask.description, desc); return newTask; } /* Save the list to a file param: heap pointer to the list param: filePtr pointer to the file to which the list is saved pre: The list is not empty post: The list is saved to the file in tab-delimited format. Each line in the file stores a task, starting with the task priority, followed by a tab character (\t), and the task description. The tasks are not necessarily stored in the file in priority order. */ void saveList(DynArr *heap, FILE *filePtr) { /* FIX ME */ } /* Load the list from a file param: heap pointer to the list param: filePtr pointer to the file pre: none post: The tasks are retrieved from the file and are added to the list. Refer to the saveList() function for the format of tasks in the file */ void loadList(DynArr *heap, FILE *filePtr) { /* FIX ME */ } /* Print the list param: heap pointer to the list pre: the list is not empty post: The tasks from the list are printed out in priority order. The tasks are not removed from the list. */ void printList(DynArr *heap) { /* FIX ME */ } /* Compare two tasks by priority param: left first task param: right second task pre: none post: none ret: -1 if priority of left < priority of right 1 if priority of left > priority of right 0 if priority of left = priority of right */ int compare(TYPE left, TYPE right) { if (left.priority < right.priority) return -1; else if (left.priority > right.priority) return 1; else return 0; }

__MACOSX/hw5/BonusHW_export /._toDoList.c

Respond to at least two of your classmates’ postings 

TAMMY’S POST:

People in need of services often do not look for or get denied access to mental health and addiction services due to social stigmas.

Recent national legislation or policy efforts help and hurt the battle against stigmas

Legislation has the power to make things happen for the better or worse. For the affluent, where the money is of no issue, mental instability and illness and action and substance abuse are viewed more acceptable and treated because affordability is not a factor. In the poor and working-class cases, insurances either do not cover services or cause obstacles in employment schedules, discrimination from employers, or a loss of wages to attend services that may be free or little to no cost. According to Stuart (2016), in 1990, half of the leading causes of disability were mental illness globally and much-needed insurance. Many of the faces that account for the population do not have or cannot afford insurance. Many also face being ineligible for federal or state-funded programs like Medicaid.

Future from a national policy perspective to reduce Stigmas

Writing into law acknowledgments such as the 21st Century Cures Act of 2016 addresses accountability and the necessity to coordinate behavioral health disorders at the federal level (SAMSA, 2020). Mental health and substance abuse need a big push because it is a big issue. The catch is all the writing in the world solves nothing unless action is taken. Attitude and approach shape how the public arena views many developments, including the care of populations affected by mental illness, addiction, and disabilities. Suppose the government shows a caring perspective and expresses concern with statistical evidence-based data to back them. In that case, a societal view changes to aid in the problem instead of ignoring or minimalizing the issue(s) at bay. These issues or contributors must be broken down from cultures and the key roles that create or promote rising numbers or mental and substance abuse problems. By solving the core culprits, a more considerable impact is made to better open funding and attention to going more in-depth to eradicate ideally social problems swept under the rugs. (Stuart, 2016).

Ensuring people needing services for mental illness and substance abuse have access to these services as a Human Services Professional

As a Social Services Worker in Medicaid and Medicare, mental health and substance abuse programs are included in benefits. A problem, however, stays in that not everyone is eligible. For instance, with the newer Heritage Health Adult Program (HHA) in Nebraska in October 2020, people age 19-64 must still meet low-income guidelines or be found medically frail by a physician. The income must not exceed 17k per individual; a meek wage is $9.00 here in the Midwest state, and rural areas offer less pay than waitressing, yet the wage exceeds income standards. Although this pilot was voted upon and won, it does mean a victory for all. Simultaneously, improvements to better the frail can show how such movement better productivity and overall well-being in homes and communities, leading the government to move most times.

Care plans to be improvised for clients with mental health and substance abuse problems

A stable home and income are crucial for those lacking mental health competency and struggling with addictions. Afflicted populations are faced with higher dysfunction due to the issues which snowball each other in the home and workplace. Employment needs to offer flexibility instead of reprimand. Step by step programs with continual resources for supporting such sponsors and groups for support is critical. Whether people deem substance abuse and mental illness a disease or a decision, the condition must be confronted and cared for with a sense of dignity.

References

Stuart, H. (2016). Reducing the stigma of mental illness. Global Mental Health, 3, e17. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5314742/

Substance Abuse and Mental Health Services Administration (SAMHSA). (2020). Laws and Regulations. Retrieved from https://www.samhsa.gov/about-us/who-we-are/laws-regulations

HEATHER’S POST:

How have recent national legislation or policy efforts helped or hurt the battle against these stigmas?

The first big issue with this topic is the constant separation of mental illness and substance abuse disorders. When looking at the ICD-10 or DSM 5 codes these two are grouped in the same category. This is the same as having anxiety, depression, or PTSD. They are all mental illnesses someone can be diagnosed with but substance abuse is always singled out which that in of itself creates the stigma that people with addictions should not be treated the same as other mental health issues. National policies have been created to “protect” those you are diagnosed with mental illnesses but they end up hurting them and tearing apart families. Yes, there are many programs or government funding assistance that someone can apply for but sadly if they apply it creates a red flag that they are unfit or a trouble maker. The article Stigma as related to Mental Disorders states “persons who disclose a history of mental disorder often cannot receive or renew a driver’s license, vote or serve on a jury, hold office, or maintain custody of their children” (Hinshaw & Stier, 2008 p. 383).  How can legislation create programs or policies to help people but take away their drivers license or right to vote, people should not have to choose between assistance and ability to drive.

What can be done in the future from a national policy perspective to reduce these stigmas?

The biggest way for national policy to be affective and create change is education. There is a severe lack of knowledge and understand on all mental illnesses. I cannot count the number of movies or television shows that portray someone with an addiction as abusive or homeless. Do not get me wrong there are situation such as that but as a substance abuse counselor my clients were your child’s kindergarten teacher, primary care physician, lawyer, next door neighbor. Mental illness can affect anyone and everyone they do not discriminate just because you have lots of money or came from a bad family. I believe this is where things need to start, by educating legislators on the true needs and fears of those with mental illnesses the real help can start.  

As a human services provider what could you do to ensure people needing services for mental illness and substance abuse had access to these services?

As a human services provider my job is to advocate and again educate the public. The stereotypes and stigmas that have circulated society for hundreds of years have to be changed and that will only happen by having hard discussions. When local politicians are speaking about allocating money to programs we should talk about the issues our clients face and attempt to convince those politicians the money or aid should go to them.

What unique needs do you believe these clients would have that you would consider as you plan services for them?

This population can have a long list of needs and the immediate thoughts are housing, food, clothes but what about the little things. There are many people who do not have the means to buy feminine hygiene products, dentures, and glasses. It is important that we do not forget the little things and move on once the main needs are met.

References:

Hinshaw, S. P., & Stier, A. (2008). Stigma as related to mental disorders. Annu. Rev. Clin. Psychol., 4, 367-393.

Guided Response: Review several of your classmates’ posts, and respond to at least two. Compare the answers of your classmates to yours. Notice any similarities and differences to teaching adult vs K-12. You might choose to respond to one person who is writing about the adult content and one who is writing about the K-12 context.

SHIMIKA’S POST:

Children or Students in a K-12 Learning Context 

Identify how this teacher promotes comprehensible input. 

The teacher promotes comprehensible input through songs, sight words, body movement, and visuals. 

Explain some of the complications of teaching ELLs that are presented by this teacher. 

The teacher stated how it was easier to motivate the elementary students verses the high school or older students. She also stated that parental involvement was higher with elementary level students. She mentioned how learning this language was a survival mechanism and that most students had to be advocates for their families. 

What ideas would you have for a teacher to overcome those challenges, based on what we have been learning? 

Some ideas that I would have for any teacher to overcome challenges is to research the cultural background, find out what makes them happy/sad. What are some things they are accustom to?  Also, to know your students, know what they will/will not do and understand why things happen. Familiarize yourself with different languages. 

Infer some cultural challenges that teachers should be aware of. 

Some culture challenges that teachers should be aware of is knowing the culture background of each student, it will help you to understand why things happen or the behavior of the student. 

How can this be impacted by Culture Shock? 

This can be impacted by culture shock because being in an unfamiliar setting causes an individual to be stressed and have anxiety. An individual has already learned something one way now they have to re-learn it in the current culture. It creates a lot of frustration having to re-do things that you already know, especially for those individuals that have difficulty learning the English language. 

Distinguish the strategies this teacher recommends. 

The strategy this teacher uses incorporates more parental involvement and encourages the parents to continue using the first language at home, so the students will have access to both languages. 

After listening to the teacher, outline strategies you would recommend. 

I would recommend anything that is beneficial to the students’ success. If that means more trainings and researching different cultures, then that is what I recommend. Learn how they do things, this way you can better relate to the student. 

Infer and describe how this teacher utilizes BICS, CALP, comprehensible input, silent period, language proficiency, total physical response, assessment, affective filter, scaffolding/differentiation. 

The teacher demonstrates teacher modeling which lets the student see exactly what it is that they are supposed to be doing. Writing persuasive letters and providing the student with anchor charts. The students can work in groups and engage in story mapping and idioms are also being utilize. 

Allen, T. [Taylor Allen]. (2014, February 4).  Interview with ELL teacher  (Links to an external site.) (Links to an external site.) [Video file]. Retrieved from https://youtu.be/OBL5orPLxyk 

MELISSA’S POST:

Identify how this teacher promotes comprehensible input.

The teacher uses several tools to promote comprehensible input like the use of chants, visuals, song and dance, sight words, and vocabulary tier 2-word practice, as well as writing.

Explain some of the complications of teaching ELLs that are presented by this teacher.

Some challenges that I found the teacher speaking about is getting the older children to be more involved and engaged with the lessons and activities, as they are harder to motivate. Another challenge for the older groups was that the parent involvement is lower, and this hinders the child’s willingness and ability to learn because the parents are not active in their child’s academics.

What ideas would you have for a teacher to overcome those challenges, based on what we have been learning?

One idea is that I would first ask the parents to come in for a parent-teacher conference. I would then explain the importance of their involvement in the classroom and their child’s education and how research tells us that children whose parents are actively involved do better in school. I would ask them what I could do to help them become more comfortable and become more involved. I would then ask the parents to come into the classroom while the students were there and speak to the class about their culture and things that are important to them. When we give the parents the opportunity to teach us about their culture, this helps the parents, and their children feel that they are a welcomed member of the community and that their culture matters.

To help with the motivation of the older students, I think that the first thing a teacher can do is to build strong and positive relationships with their students. Children want to please and be heard, they want to make a difference, and they want to feel loved and appreciated. When teachers show that the children have a more positive outlook on life in general which will carry over to their academics. Additionally, making the lessons, fun and enjoyable for the students will increase their motivation to learn because they are not bored and frustrated.

Some cultural challenges that teachers should be aware of.

Teachers need to make sure that they are prepared for the children who come into their classroom from different cultures. There are so many differences that we see throughout the many different cultures. Like in some cultures making eye contact is considered a rude gesture, and other cultures are much louder and social, like the Germans or Italians, whereas the Asian culture is quieter and more reserved. There are also a lot of differences between their home lives and how they live in the home. Some cultures live with many members of their family all under one roof, whereas others live within just their immediate families. All this plays into the child’s ability to learn and helping them to be comfortable in the classroom.

How can this be impacted by Culture Shock?

I think that the first thing we all need to understand is that Culture Shock is a real thing. We must know what it looks like for the students to be able to help the students overcome it. Knowledge is the best way for teachers to learn about Culture Shock and how to assist the child when they enter their classroom. Another thing that can be impacted by culture shock is the relationship that the teacher has with the parents. The parents are also going to struggle with some sort of culture shock and knowing that the teachers can be a little more sensitive when speaking with the families, they can be prepared with an interpreter to help them communicate with the families and they can use visuals, etc. to help the families follow along with the discussion. If a teacher is not aware of all the challenges of culture shock, they will not be able to successfully handle the challenges when they arrive.

Distinguish the strategies this teacher recommends.

The strategy that the teacher recommended is first being aware of all the students in the classroom and their culture. Then using activities that are paired with visuals, songs, dance, chants, sight words, etc. to help the children.

After listening to the teacher, outline strategies you would recommend.

I would recommend a fun teacher – family outing. Maybe a potluck at the local park by the school, or even at the school itself. This would be a great way to get to know the parents, children, and culture better, as well as get the other families and peers to get to know each other outside of school. When we help these children and families build strong relationships in the classroom and in the community, they can start to feel more comfortable and accepted in their new surroundings.

The teacher can also encourage the students to use not only English in the classroom but also their native tongue, she could have books, visuals, songs, etc. in the native language for the child to use.

 Additionally, I would suggest that the teacher assess the children on day one in both their native tongue and in English. Maybe having an interpreter present for the child so that the teacher can understand more deeply the child’s use of language and their understanding of it. This would help the teacher to make a better placement choice for the child. Then throughout the time in the classroom, I would suggest using different assessments on the children because we have learned that they are no one-size-fits-all tool. There are many different assessments tools that one can choose from to help bridge the gap of what the child is able to communicate and/or show off their progress.

REFERENCES

Piper, T. (2015). Language, learning, and culture: English language learning in today’s schools. Retrieved from https://content.ashford.edu (Links to an external site.)

Allen, T. [Taylor Allen]. (2014, February 4). Interview with ELL teacher  (Links to an external site.) (Links to an external site.) (Links to an external site.) [Video file]. Retrieved from https://youtu.be/OBL5orPLxyk 

Guided Response: Review several of your classmates’ posts, and respond to at least two. Compare your answers to your classmates’ answers. Notice any similarities and differences between your Mind Maps. What connections were similar to yours? What connections were different, but logical? For distinguished peer responses, respond with a minimum of five sentences that add to the conversation, and refrain from evaluative posts (i.e., You did a good job.).

MELISSA’S POST:

https://ashford.instructure.com/users/204673/files/14962126/preview?verifier=jX4q7LA2LM4NaPpMoPiRL1Ofh87pmFVjpZF1vSH1

Sorry about the Bubble symbol coving the assessment bubble, I could not figure out how to move it. lol

I chose to use English as a Second Language as my first bubble because that is the major topic of the vocabulary mind map. The nest three bubbles share the importance as they are what teachers need to focus on to help the English Language Learners grow academically. The Language Proficiency Level is very important to diagnose right from the beginning as this will lay the groundwork when placing the child in the appropriate setting. The Four Domains of Language is next because it is the goals that teachers are trying to have their students reach, speaking, listening, reading, and writing. Then I place Communicating Language Teaching (CLT) next because the teachers must know the approach that they are wanting to take to teach the language that emphasizes interaction as both the means and the ultimate goal of the lesson. Under Language Proficiency Level I listed the Affective Filter and Comprehensible Input, teachers cannot get their students to become fluent or proficient in the English language if they do not understand how the affective filter and comprehensible input work together. Under the Four Domains of Langauge, I listed the Language Objectives. Once the teacher is aware of the child’s ability to learn they will need to develop Language Objectives that are developmentally appropriate for their students. Next, you will see that I listed BICS and CALP under Communicative Language Teaching because BICS is language that is used every day and CALP is language that is used in academic settings.  Finally, to tie it all together I listed Assessment because this is what the teachers need to use to find out where the student is.  Once the assessment is complete the teacher should be able to determine where that child is in their academic skills and develop additional lessons to take them to the next step. 

SHIMIKA’S POST:

https://ashford.instructure.com/users/231902/files/14975434/preview?verifier=RJ1Q329alW8rZmjAQHXPUfadhXtX4WL9nnOx75X3

English as a second language is my first point of contact because it is the main objective for this course. The next two headings consist of language objectives(left) and the four domains of language(right). Language objectives focuses on what the student will need to learn to accomplish their academic goal. The four domains of language are reading, writing, speaking, and listening, these are skills that help assist  with  learning the English language. Below language objectives is comprehensible input which is based on the information the students’ receive and how well they understand it. Next, under four domains of language there is language proficiency levels that measures how well a level is mastered. The next column(right) is Realia focuses on everyday life skills that teachers use to help students. The next column (left) are productive and receptive skills. These two skills are associated with the four domains of language that include speaking and writing that are based on output language. Reading and listening are based on the (input) it determines how well the  student comprehends the information that they receive. The last column underneath Realia is BICS and CALPS which are the informal and formal way of communicating with others on a friend/ academic level. All these words are connected to one another because they all have to do with learning the English language.

Order your essay today and save 10% with the discount code ESSAYHELP