Saturday, January 25, 2020

Research Assignment on Data File Structure

Research Assignment on Data File Structure Raghavendra Tyagi TOPIC OF ASSIGNMENT The letters in English language, make up words. While no word is less or more than another, one could view a word that appears before another in the dictionary is less than that word, and a word that appears afterwards is more. By this definition, identical words are the same. Parsing a file is when you read a file to collect information from the file. In this assignment, you will parse a file, and put all of the words in a Binary Search Tree. You will use the Binary Search Tree to collect data about the number of times a word was found in the file. The first word you encounter will be the root. If the next word is greater, put it to the right. If it is less, put it to the left. It is possible that the tree you make will be very sparse. Assume all words in the file are lower case or covert them to lower case. After you have loaded the file into your Binary Search Tree, the program should display the in-order, pre-order post-order traversal of the Binary Search Tree. The user should be given the chance to type a word. The computer should say the number of times the word was found in the file (zero or more). BINARY SEARCH TREE INTRODUCTION: In  computer science, a binary search tree (BST), sometimes also called an ordered or sorted binary tree, is a  node-based  binary tree  data structure which has the following properties The left  sub tree  of a node contains only nodes with keys less than the nodes key. The right sub tree of a node contains only nodes with keys greater than the nodes key. The left and right sub tree each must also be a binary search tree. There must be no duplicate nodes ADVANTAGE: The major advantage of binary search trees over other  data structures  is that the related sorting Algorithm and  search algorithms  such as  in-order traversal  can be very efficient. BINARY SEARCH TREE (PROPERTY): Letxbe a node in a binary search tree. Ifyis a node in the left sub tree ofx, theny. key x. key. OPERATIONS: Operations, such asfind, on a binary search tree require comparisons between nodes. These comparisons are made with calls to a comparator, which is a  subroutine  that computes the total order (linear order) on any two keys. This comparator can be explicitly or implicitly defined, depending on the language in which the binary search tree was implemented. SEARCHING: Searching a binary search tree for a specific key can be a  recursive  or an  iterative  process. We begin by examining the  root node. If the tree isnull, the key we are searching for does not exist in the tree. Otherwise, if the key equals that of the root, the search is successful and we return the node. If the key is less than that of the root, we search the left sub tree. Similarly, if the key is greater than that of the root, we search the right sub tree. This process is repeated until the key is found or the remaining sub tree is null. If the searched key is not found before a null sub tree is reached, then the item must not be present in the tree. INSERTION: Insertion begins as a search would begin; if the key is not equal to that of the root, we search the left or right sub trees as before. Eventually, we will reach an external node and add the new key-value pair (here encoded as a record new Node) as its right or left child, depending on the nodes key. In other words, we examine the root and recursively insert the new node to the left sub tree if its key is less than that of the root, or the right sub tree if its key is greater than or equal to the root. DELETION: There are three possible cases to consider: Deleting a leaf (node with no children):Deleting a leaf is easy, as we can simply remove it from the tree. Deleting a node with one child:Remove the node and replace it with its child. Deleting a node with two children:Call the node to be deletedN. Do not deleteN. Instead, choose either its  in-order  successor node or its in-order predecessor node,R. Replace the value ofNwith the value ofR, then deleteR. BST FIGURE: Preorder traversal sequence: F, B, A, D, C, E, G, I, H (Root, left, right) In order traversal sequence: A, B, C, D, E, F, G, H, I (left, root, right) Post order traversal sequence: A, C, E, D, B, H, I, G, (left, right, root) ASSIGNMENT CODE #include #include struct treeNode { char data[10]; struct treeNode *left, *right; }; struct treeNode *root = NULL; struct treeNode* createNode(char data) { struct treeNode *newNode; newNode = (struct treeNode*)malloc(sizeof(struct treeNode)); newNode->data = data; newNode->left = NULL; newNode->right = NULL; return(newNode); } void insertion(struct treeNode **node, char data) { if (*node == NULL) { *node = createNode(data); } else if (data data) { insertion((*node)->left, data); } else if (data > (*node)->data) { insertion((*node)->right, data); } } void deletion(struct treeNode **node, struct treeNode **parent, char data) { struct treeNode *tmpNode, *tmpParent; if (*node == NULL) return; if ((*node)->data == data) { if (!(*node)->left !(*node)->right) { if (parent) { if ((*parent)->left == *node) (*parent)->left = NULL; else (*parent)->right = NULL; free(*node); } else { free(*node); } } else if (!(*node)->right (*node)->left) { tmpNode = *node; (*parent)->right = (*node)->left; free(tmpNode); *node = (*parent)->right; } else if ((*node)->right !(*node)->left) { tmpNode = *node; (*parent)->left = (*node)->right; free(tmpNode); (*node) = (*parent)->left; } else if (!(*node)->right->left) { tmpNode = *node; (*node)->right->left = (*node)->left; (*parent)->left = (*node)->right; free(tmpNode); *node = (*parent)->left; } else { tmpNode = (*node)->right; while (tmpNode->left) { tmpParent = tmpNode; tmpNode = tmpNode->left; } tmpParent->left = tmpNode->right; tmpNode->left = (*node)->left; tmpNode->right =(*node)->right; free(*node); *node = tmpNode; } } else if (data data) { deletion((*node)->left, node, data); } else if (data > (*node)->data) { deletion((*node)->right, node, data); } } void findElement(struct treeNode *node, chardata) { if (!node) return; else if (data data) { findElement(node->left, data); } else if (data > node->data) { findElement(node->right, data); } else printf(data found: %sn, node->data); return; } void traverse(struct treeNode *node) { if (node != NULL) { traverse(node->left); printf(%3d, node->data); traverse(node->right); } return; } int main() { char data; int ch; while (1) { printf(1. Insertion in Binary Search Treen); printf(2. Deletion in Binary Search Treen); printf(3. Search Element in Binary Search Treen); printf(4. Inorder traversaln5. Exitn); printf(Enter your choice:); scanf(%d, ch); switch (ch) { case 1: while (1) { printf(Enter your data:); scanf(%s, data); insertion(root, data); printf(Continue Insertion(0/1):); scanf(%d, ch); if (!ch) break; } break; case 2: printf(Enter your data:); scanf(%s, data); deletion(root, NULL, data); break; case 3: printf(Enter value for data:); scanf(%s, data); findElement(root, data); break; case 4: printf(Inorder Traversal:n); traverse(root); printf(n); break; case 5: exit(0); default: printf(uve entered wrong optionn); break; } } return 0; } [[emailprotected] ~]$vi t.c [[emailprotected] ~]$gcc t.c [[emailprotected] ~]$./a.out OUTPUT: 1. Insertion in Binary Search Tree 2. Deletion in Binary Search Tree 3. Search Element in Binary Search Tree 4. Inorder traversal 5. Exit Enter your choice:1 Enter your data: aim Continue Insertion(0/1):1 Enter your data: age Continue Insertion(0/1):1 Enter your data: admit Continue Insertion(0/1):1 Enter your data: agree Continue Insertion(0/1):1 Enter your data: blue Continue Insertion(0/1):0 Resultant Binary Search Tree after insertion operation: aim / age blue / admit agree 1. Insertion in Binary Search Tree 2. Deletion in Binary Search Tree 3. Search Element in Binary Search Tree 4. Inorder traversal 5. Exit Enter your choice:4 Inorder Traversal: admit, age, agree, aim , blue 1. Insertion in Binary Search Tree 2. Deletion in Binary Search Tree 3. Search Element in Binary Search Tree 4. Inorder traversal 5. Exit Enter your choice:2 Enter your data:admit Delete node admit aim / age blue / agree 1. Insertion in Binary Search Tree 2. Deletion in Binary Search Tree 3. Search Element in Binary Search Tree 4. Inorder traversal 5. Exit Enter your choice:3 Enter value for data:age data found: age No of occurrence:1 1. Insertion in Binary Search Tree 2. Deletion in Binary Search Tree 3. Search Element in Binary Search Tree 4. Inorder traversa 5. Exit Enter your choice:5[[emailprotected] ~]$ COMPLEXITY OF BINARY SEARCH TREE It could be O(n^2) even if the tree is balanced. Suppose youre adding a sorted list of numbers, all larger than the largest number in the tree. In that case, all numbers will be added to the right child of the rightmost leaf in the tree, Hence O(n^2). For example, suppose that you add the numbers [15..115] to the following tree: The numbers will be added as a long chain, each node having a single right hand child. For the i-th element of the list, youll have to traverse ~i nodes, which yields O(n^2). In general, if youd like to keep the insertion and retrieval at O(nlogn), you need to use  Self Balancing trees

Friday, January 17, 2020

Drovers Wife

Comparing the female characters in the short stories The Drover's Wife by Henry Lawson and The Chosen Vessel by Barbara Baynton. †¢Brief biography of Henry Lawson and Barbara Baynton. †¢The Drover's wife was published in the Bulletin in 1892 and The Chosen Vessel in 1896. †¢From the 1900s to the onset of WW1, pioneers made their homes in the dangerous outback of Australia. †¢Pioneering women are left alone to encounter the scourge of nature ( examples). The women became principal caregivers to sick travelers. †¢Most of these women rose to the challenge and endured the incredible hardship of life in the outback. Brief summary of both stories. The Drovers Wife revolves around the hardship and bravery of a bush woman who lives with her 4 children and snake dog. The Chosen Vessel is about a bush woman who is left alone and one day, she encounters a swagman who rapes and murders her. †¢The themes for both stories are similar – loneliness of being in th e bush and battling an enemy to save their children and themselves. †¢The drover's wife fights through many battles during her husband's absence. She suffered several hardships. †¢The woman in â€Å"The Chosen Vessel† is also left alone to care for her young child when faced with dangers. In â€Å"The Drover's Wife† the enemy is the five-foot long poisonous snake. The snake that the woman battles against is a representative of her enemy which is the bush. Throughout her whole life, she has been battling against nature. †¢The enemy in â€Å"The Chosen Vessel† is the swagman. The woman is fighting against man, her husband and the swagman. †¢The ways in which both the women approach the dangers they are faced with are different. †¢The drover's wife attacks and faces her problems whereas the woman in † The Chosen Vessel† hides from hers. †¢The lies in which each women tells the swagmen they come across emonstrates their diff erent characters. †¢Both the women have different respects and expectations from their husband. †¢The drover's wife respects his husband and knows that he if he had the means, he would treat her like a princess. †¢The husband of the woman in â€Å"The Chosen Vessel† is cruel to his wife. Despite being ill-treated, she still counts the days till his homecoming even though he had not been gone for long. †¢The emotions of the women vary in each story. †¢Beneath her tough exterior, the drover's wife is a sensitive and emotional. woman. †¢The only emotion shown by the woman in Barbara Baynton's story is fear. The drover's wife may be more physically isolated, but she had been given help from various people. The other woman however, is left completely alone to care for her young child. †¢Although both stories revolved around the same theme, time and setting, the presentation of the setting through their characters gave a different representation t o the readers. †¢Henry Lawson's writing was more favorable compared to Barbara Baynton's gothic style. His story succeeded in giving tribute and admiration to the hardship and struggles of the Australian bush people.

Thursday, January 9, 2020

Essay on Analysis of Everyday Use by Alice Walker - 631 Words

The story Everyday Use, written by Alice Walker, is a story of heritage, pride, and learning what kind of person you really are. In the exposition, the story opens with background information about Dee and Maggies life, which is being told by Mama. The reader learns that Dee was the type of child that had received everything that she wanted, while Maggie was the complete opposite. The crisis, which occurs later in the story, happens when Dee all of a sudden comes home a different person than she was when she left. During the Climax, Mama realizes that she has often neglected her other child, Maggie, by always giving Dee what she wants. Therefore, in the resolution, Mama defends Maggie by telling Dee that she cannot have the†¦show more content†¦Mama could be defined as a round character in the story because of the change she undergoes at the end. Mama?s goes through a dramatic change in the story when she gets up the nerve to tell her aggressive, non-hesitant daughter ?No?, and gives her other daughter Maggie, who has often been on the bad end of things, the household items for her marriage. Dee could probably be considered a main character in the story, but her change was too simple, because she changed on the outside only, and because she didn?t change on the day that the story occured. Mama stated ?When I looked at her like that something hit me in the top of my head and ran down to the souls of my feet. Just like when I?m in church and the spirit of God touches me and I get happy and shout? (94). Maggie did not have a lot of input in the story although she did change a little, both were flat characters. Mama is a more in-depth character than Dee and Maggie because the reader is given very descriptive attributes of her physically and mentally. Dee did not want to quilt to remember her heritage by, but instead to hang it up on the wall like some sort of trophy to show others where she has come from. She loves her family very much, but is ashamed of the surroundings she grew up in. Overall, Mama?s change had a big impact on the story due to the fact that she went f rom a woman who had low self esteem and was scared toShow MoreRelatedEveryday Use by Alice Walker an Analysis1049 Words   |  5 PagesTamica Powell September 30, 2011 Everyday Use Analysis Everyday Use is a compelling story of a mothers conflicting relationships with her two daughters. Maggie, which the mother feels contains more practical and traditional ways of living life and then Dee her oldest and most promising daughter, who she feels has broken away from tradition and has lost a lot of their heritage. At first glance you would see this as the normal mother daughter spat of maybe the wild child versus the littleRead MoreAnalysis Of Everyday Use By Alice Walker951 Words   |  4 PagesAn Analysis of three messages from Everyday Use Do you know where your mother got her wedding ring? Most people get their rings from their parents and pass it down to their first child usually. This is probably the most commonly past heirloom, but some families have other heirlooms. Heirlooms are something that is passed down from generations to generation. It will usually be very old and valuable, from it traveling around the world to the Americas or from a great great grandparent. Alice WalkerRead MoreLiterary Analysis Of Everyday Use By Alice Walker1083 Words   |  5 PagesUse (Literary analysis on Everyday Use by Alice Walker) Everyday many people use the same things such as phones, cars, sinks, washer, refrigerators, and etc. In 100 years would you can future ancestors still have those things but only use them as decoration or use them still no matter how old they are because that is what they are made for? Everyday Use by Alice walker is a story of an African American family that had two daughter that live a very different reality. Maggie being scarred from aRead MoreEveryday Use By Alice Walker Analysis978 Words   |  4 PagesUnderstanding Everyday Use by Alice Walker One of the most monumental short stories of the twentieth century is Alice Walker’s â€Å"Everyday Use.† By carefully considering the use of point of view, a better understanding of the story’s meaning will be obtained. It will be possible to appreciate how diverse language patterns and cultural differences may impact the understanding of characters and conflict situations. Everyday Use is a unique story as it places the voice of an African American woman atRead MoreEveryday Use By Alice Walker Analysis971 Words   |  4 PagesThrew different Eyes The story Everyday use would seem very different if told from someone else but not Mama. Think of having a friend/girlfriend that is very smart and sophisticated. Then going to visit her family with her. Also getting there and her family nothing like her. They do not think the same act the same and/or look the same. Then they are arguing over something that seems pointless and useless. Everything they eating looks nasty and/or taste nasty. Alternatively, being the younger siblingRead MoreAnalysis Of `` Everyday Use `` By Alice Walker1315 Words   |  6 Pagescultures to which one is then to perceive the culture a specific way. Culture is the multitude of many factors in which it consistently informs one s perception of the world surrounding them as well as the individuals. For instance, in Alice Walker s Everyday Use, two sisters, Maggie and Dee, lived together with their mother. In the story, the mother sends Dee away ,to send her Augusta to school. Afterwards, the mother explained that ,she used to read to us without pity, forcing words, lies,Read MoreAnalysis Of Everyday Use By Alice Walker1007 Words   |  5 PagesThe Better Sister The short story of â€Å"Everyday Use† was written by Alice Walker. Mrs. Johnson is the narrator of the story. In this petite narrative, Mrs. Johnson and her youngest daughter Maggie get a visit from her oldest daughter Dee who graduates from college and Mrs. Johnson and Maggie both bear witness to Dee’s change. As Dee is trying to embrace the modern culture in the twentieth century. Thus, in Alice Walker’s story, Mrs. Johnson’s perspective changes at the end, at first favoring DeeRead MoreEveryday Use By Alice Walker Analysis1538 Words   |  7 Pagesâ€Å"Everyday Use† Historical Criticisms explored the disconnection that people can sometimes have depending on their education. Alice Walker successfully shows the disconnection by comparing two ends of the spectrum of generation. Taking the historical context, it plays a major role in the way this short story is viewed. It was a time where people of color had a different and difficult experience ge tting an education. When the narrator was talking about having an education it was important because sheRead MoreAnalysis Of Everyday Use By Alice Walker1826 Words   |  8 Pagesculture is something that shapes and tells others who you are. For example, in Alice Walker’s short story â€Å"Everyday Use† you are introduced to Mrs. Johnson and two other characters that are loose portrayals of Walker in her younger and older periods of life (Obaid). The first one being Maggie who is depicted as her younger more walled self and the other being Dee an older version of Walker who lightly symbolizes Walkers later beliefs through some of the actions she takes in the story (Obaid). As theRead MoreCritical Analysis Of Alice Walker s Everyday Use2414 Words   |  10 PagesTulsi Rizal Prof. Mary Huffer Eng122 24 April 2016 Critical Analysis of Alice Walker’s â€Å"Everyday Use† Alice Walker, most revered African American writer of the present time was born on 9th February 1944 in Eatonton, Georgia. She started her career as a social worker/activist, followed by teaching and and being a writer. She has won many awards for her fantastic social and literary works. Everyday use† was published in 1973, when African Americans were struggling to revive their original African culture

Wednesday, January 1, 2020

Infamous serial killer, John Wayne Gacy, was born on March...

Infamous serial killer, John Wayne Gacy, was born on March 17, 1942, in Chicago, Illinois. Gacy, born into an abusive environment, was assaulted physically along with his siblings, with a razor strap if they were perceived to have misbehaved by their alcoholic father. In addition, Gacy’s mother was physically abused as well throughout her marriage and during the children’s upbringing. During John Wayne Gacy’s childhood education, he suffered further alienation due to a congenital heart condition that resulted in further feelings of contempt from his father. Furthermore, Gacy eventually came to the realization that he was attracted to men, which caused a great amount of mental turmoil over his sexuality. John Wayne Gacy was married and†¦show more content†¦A police search of Gacy’s house in Des Plaines, Illinois, on December 21, exposed evidence of his involvement in numerous abominable acts, including murder. John Wayne Gacy, it would later be det ermined, had murdered thirty-three boys and young males, the majority of whom had been buried under his dwelling and garage, while around four to five other victims would be recovered from the nearby Des Plaines River. The victims were lured to Gacy’s dwelling with the promise of construction work, and then captured, sexually assaulted, and then eventually strangled to death with rope. Furthermore, John Wayne Gacy sometimes dressed as his alter ego â€Å"Pogo the Clown†, when he murdered. After a short jury deliberation, John Wayne Gacy was ultimately found guilty of committing thirty-three murders and became known as one of the most vicious serial killers in U.S. history. Gacy was sentenced to serve twenty-one natural life sentences and serve twelve death sentences. For almost a decade and a half, Gacy was imprisoned at the Menard Correctional Center where he appealed the sentence and offered contradictory statements on the murders in interviews. Although Gacy had confessed, later he had vehemently denied being guilty of the charges. John Wayne Gacy ultimately died by lethal injection on May 10, 1994, at the Stateville Correctional Center in Crest Hill, Illinois; with both anti-death penalty forces