ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 12 Weeks Ago, 6 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 04 May 2017 My Price 12.00

CSCI 2270 – Data structures and algorithms

C++, Please read the attached assignment included! Basically need someone to read in a book into an array of structs and then find the unique words outside the normal word listed in the project. Complete instructions in the attachments.

 

 

CSCI 2270 – Data structures and algorithms Instructor: Hoenigman Assignment 2 Due Friday, February 3 before 3pm Word analysis There are several fields in computer science that aim to understand how people use language. This can include analyzing the most frequently used words by certain authors, and then going one step further to ask a question such as: “Given what we know about Hemingway’s language patterns, do we believe Hemingway wrote this lost manuscript?” In this assignment, we’re going to do a basic introduction to document analysis by determining the number of unique words and the most frequently used words in two documents. Please read all directions for the assignment carefully. This write-up contains both the details of what your program needs to do as well as implementation requirements for how the functionality needs to be implemented. What your program needs to do There is one test file on Moodle – HungerGames_edit.txt that contain the full text from Hunger Games Book 1. We have pre-processed the file to remove all punctuation and down-cased all words. Your program needs to read in the .txt file, with the name of the file to open set as a command-line argument. Your program needs to store the unique words found in the file in a dynamically allocated array and calculate and output the following information: • The top n words (n is also a command-line argument) and the number of times each word was found • The total number of unique words in the file • The total number of words in the file • The number of array doublings needed to store all unique words in the file There is a link to a class video on command-line arguments in the Resources section of piazza. Example: Running your program using: ./Assignment2 HungerGames_edit.txt 10 would return the 10 most common words in the file HungerGames_edit.txt and should produce the following results. 682 - is
492 - peeta
479 - its
431 - im
427 - can
414 - says
379 - him
368 - when
367 - no
356 - are
#
Array doubled: 7
#
Unique non-common words: 7682
#
Total non-common words: 59157 Program specifications Use an array of structs to store the words and their counts There are specific requirements for how your program needs to be implemented. For this assignment, you need to use an array of structs to store the words and their counts. The members of the struct are left to you, but keep it as simple as possible. Exclude these top 50 common words from your word counting Table 1 shows the 50 most common words in the English language. In your code, exclude these words from the words you count in the .txt file. Your code should include a separate function to determine if the current word read from the .txt file is on this list and only process the word if it is not. Table 1. Top 50 most common words in the English language Rank 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Word The Be To Of And A In That Have I It For Not On Rank 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Word You Do At This But His By From They We Say Her She Or Rank 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Word One All Would There Their What So Up Out If About Who Get Which 15 With 32 An 49 Go 16 He 33 Will 50 Me 17 As 34 My Use two command-line arguments Your program needs to have two command-line arguments – the first argument is the name of the file to open and read, and the second argument is the number of most frequent words to output. For example, running ./Assignment2 HungerGames_edit.txt 20 will read the HungerGames_edit.txt file and output the 20 most common words found in the file. Note: There is a link to a class video on command-line arguments in the Resources section on Piazza. Use the array-doubling algorithm to increase the size of your array We don’t know ahead of time how many unique words either of these files has, so you don’t know how big the array should be. Start with an array size of 100, and double the size as words are read in from the file and the array fills up with new words. Use dynamic memory allocation to create your array, copy the values from the current array into the new array, and then free the memory used for the current array. This is the same process you used in Recitation 3. Note: some of you might wonder why we’re not using C++ Vectors for this assignment. A vector is an interface to a dynamically allocated array that uses array doubling to increase its size. In this assignment, you’re doing what happens behindthe-scenes with a Vector. Output the top n most frequent words Write a function to determine the top n words in the array. This can be a function that sorts the entire array, or a function that generates an array of the n top items. Output the n most frequent words in the order of most frequent to least frequent. Format your output the following way When you output the top n words in the file, the output needs to be in order, with the most frequent word printed first. The format for the output needs to be: Count - Word # Array doubled: <number of array doublings> # Unique non-common words: <number of unique words> # Total non-common words: <total number of words> Generate the output with these commands: cout<<numCount<<” – “<<word<<endl;
cout<<”#”<<endl;
cout<<”Array doubled: “<<numDoublings<<endl;
cout<<”#”<<endl;
cout<<”Unique non-common words: “<<numUniqueWords<<endl; Submitting Your Code: Submit your assignment to the COG autograder: https://web-cog-csci2270.cs.colorado.edu/submit.html. Login to COG using your identikey and password. Select the CSCI2270 - Hoenigman – HW #02 from the dropdown. Upload your file and click Submit. Your file needs to be named Assignment2.cpp for the grading script to run. COG will run its tests and display the results in the window below the Submit button. If your code doesn’t run correctly on COG, read the error messages carefully, correct the mistakes in your code, and upload a new file. You can modify your code and resubmit as many times as you need to, up until the assignment due date. Submit your assignment to Moodle In addition to submitting through COG, submit your .cpp file through Moodle using the Assignment 2 Submit link. Make sure your code is commented enough to describe what it is doing. Include a comment block at the top of the .cpp file with your name, assignment number, and course instructor. If you do not submit your work to Moodle, we will deduct points from your grade, even if COG gives you a perfect score. If you do not get your assignment to run on COG, you will have the option of scheduling an interview grade with your TA to get a grade for the assignment. Even if you do get the assignment to run on COG, you can schedule the interview if you just want to talk about the assignment and get feedback on your implementation. What to do if you have questions There are several ways to get help on assignments in 2270, and depending on your question, some sources are better than others. There is the Piazza forum that is a good place to post technical questions, such as how to shift an array. When you answer other students’ questions on the forum, please do not post entire assignment solutions. The CAs are also a good source of technical information, especially questions about C++. If, after reading the assignment write-up, you need clarification on what you’re being asked to do in the assignment, the TAs and the Instructor are better sources of information than the discussion forum or the CAs.

 

hunger games parti the tributes when i wake up the other side of the bed is cold my fingers stretch out seeking prims warmth but finding only the rough canvas cover of the mattress she must have had bad dreams and climbed in with our mother of course she did this is the day of the reaping i prop myself up on one elbow theres enough light in the bedroom to see them my little sister prim curled up on her side cocooned in my mothers body their cheeks pressed together in sleep my mother looks younger still worn but not so beatendown prims face is as fresh as a raindrop as lovely as the primrose for which she was named my mother was very beautiful once too or so they tell me sitting at prims knees guarding her is the worlds ugliest cat mashedin nose half of one ear missing eyes the color of rotting squash prim named him buttercup insisting that his muddy yellow coat matched the bright flower i le hates me or at least distrusts me even though it was years ago i think he still remembers how i tried to drown him in a bucket when prim brought him home scrawny kitten belly swollen with worms crawling with fleas the last thing i needed was another mouth to feed but prim begged so hard cried even i had to let him stay it turned out okay my mother got rid of the vermin and hes a born mouser even catches the occasional rat sometimes when i clean a kill i feed buttercup the entrails he has stopped hissing at me entrails no hissing this is the closest we will ever come to love i swing my legs off the bed and slide into my hunting boots supple leather that has molded to my feet i pull on trousers a shirt tuck my long dark braid up into a cap and grab my forage bag on the table under a wooden bowl to protect it from hungry rats and cats alike sits a perfect little goat cheese wrapped in basil leaves prims gift to me on reaping day i put the cheese carefully in my pocket as i slip outside our part of district 12 nicknamed the seam is usually crawling with coal miners heading out to the morning shift at this hour men and women with hunched shoulders swollen knuckles many who have long since stopped trying to scrub the coal dust out of their broken nails the lines of their sunken faces but today the black cinder streets are empty shutters on the squat gray houses are closed the reaping isnt until two may as well sleep in if you can our house is almost at the edge of the seam i only have to pass a few gates to reach the scruffy field called the meadow separating the meadow from the woods in fact enclosing all of district 12 is a high chainlink fence topped with barbedwire loops in theory its supposed to be electrified twentyfour hours a day as a deterrent to the predators that live in the woods — packs of wild dogs lone cougars bears — that used to threaten our streets but since were lucky to get two or three hours of electricity in the evenings its usually safe to touch even so i always take a moment to listen carefully for the hum that means the fence is live right now its silent as a stone concealed by a clump of bushes i flatten out on my belly and slide under a twofoot stretch thats been loose for years there are several other weak spots in the fence but this one is so close to home i almost always enter the woods here as soon as im in the trees i retrieve a bow and sheath of arrows from a hollow log electrified or not the fence has been successful at keeping the flesh eaters out of district 12 inside the woods they roam freely and there are added concerns like venomous snakes rabid animals and no real paths to follow but theres also food if you know how to find it my father knew and he taught me some before he was blown to bits in a mine explosion there was nothing even to bury i was eleven then five years later i still wake up screaming for him to run even though trespassing in the woods is illegal and poaching carries the severest of penalties more people would risk it if they had weapons but most are not bold enough to venture out with just a knife my bow is a rarity crafted by my father along with a few others that i keep well hidden in the woods carefully wrapped in waterproof covers my father could have made good money selling them but if the officials found out he would have been publicly executed for inciting a rebellion most of the peacekeepers turn a blind eye to the few of us who hunt because theyre as hungry for fresh meat as anybody is in fact theyre among our best customers but the idea that someone might be arming the seam would never have been allowed in the fall a few brave souls sneak into the woods to harvest apples but always in sight of the meadow always close enough to run back to the safety of district 12 if trouble arises district twelve where you can starve to death in safety i mutter then i glance quickly over my shoulder even here even in the middle of nowhere you worry someone might overhear you when i was younger i scared my mother to death the things i would blurt out about district 12 about the people who rule our country panem from the far off city called the capitol eventually i understood this would only lead us to more trouble so i learned to hold my tongue and to turn my features into an indifferent mask so that no one could ever read my thoughts do my work quietly in school make only polite small talk in the public market discuss little more than trades in the hob which is the black market where i make most of my money even at home where i am less pleasant i avoid discussing tricky topics like the reaping or food shortages or the hunger games prim might begin to repeat my words and then where would we be in the woods waits the only person with whom i can be myself gale i can feel the muscles in my face relaxing my pace quickening as i climb the hills to our place a rock ledge overlooking a valley a thicket of berry bushes protects it from unwanted eyes the sight of him waiting there brings on a smile gale says i never smile except in the woods hey catnip says gale my real name is katniss but when i first told him i had barely whispered it so he thought id said catnip then when this crazy lynx started following me around the woods looking for handouts it became his official nickname for me i finally had to kill the lynx because he scared off game i almost regretted it because he wasnt bad company but i got a decent price for his pelt look what i shot gale holds up a loaf of bread with an arrow stuck in it and i laugh its real bakery bread not the flat dense loaves we make from our grain rations i take it in my hands pull out the arrow and hold the puncture in the crust to my nose inhaling the fragrance that makes my mouth flood with saliva fine bread like this is for special occasions mm still warm i say he must have been at the bakery at the crack of dawn to trade for it what did it cost you just a squirrel think the old man was feeling sentimental this morning says gale even wished me luck well we all feel a little closer today dont we i say not even bothering to roll my eyes prim left us a cheese i pull it out his expression brightens at the treat thank you prim well have a real feast suddenly he falls into a capitol accent as he mimics effie trinket the maniacally upbeat woman who arrives once a year to read out the names at the leaping i almost forgot happy hunger games he plucks a few blackberries from the bushes around us and may the odds — he tosses a berry in a high arc toward me i catch it in my mouth and break the delicate skin with my teeth the sweet tartness explodes across my tongue — be ever in your favor i finish with equal verve we have to joke about it because the alternative is to be scared out of your wits besides the capitol accent is so affected almost anything sounds funny in it i watch as gale pulls out his knife and slices the bread he could be my brother straight black hair olive skin we even have the same gray eyes but were not related at least not closely most of the families who work the mines resemble one another this way thats why my mother and prim with their light hair and blue eyes always look out of place they are my mothers parents were part of the small merchant class that caters to officials peacekeepers and the occasional seam customer they ran an apothecary shop in the nicer part of district 12 since almost no one can afford doctors apothecaries are our healers my father got to know my mother because on his hunts he would sometimes collect medicinal herbs and sell them to her shop to be brewed into remedies she must have really loved him to leave her home for the seam i try to remember that when all i can see is the woman who sat by blank and unreachable while her children turned to skin and bones i try to forgive her for my fathers sake but to be honest im not the forgiving type gale spreads the bread slices with the soft goat cheese carefully placing a basil leaf on each while i strip the bushes of their berries we settle back in a nook in the rocks from this place we are invisible but have a clear view of the valley which is teeming with summer life greens to gather roots to dig fish iridescent in the sunlight the day is glorious with a blue sky and soft breeze the foods wonderful with the cheese seeping into the warm bread and the berries bursting in our mouths everything would be perfect if this really was a holiday if all the day off meant was roaming the mountains with gale hunting for tonights supper but instead we have to be standing in the square at two oclock waiting for the names to be called out we could do it you know gale says quietly what i ask leave the district run off live in the woods you and i we could make it says gale i dont know how to respond the idea is so preposterous if we didnt have so many kids he adds quickly theyre not our kids of course but they might as well be gales two little brothers and a sister prim and you may as well throw in our mothers too because how would they live without us who would fill those mouths that are always asking for more with both of us hunting daily there are still nights when game has to be swapped for lard or shoelaces or wool still nights when we go to bed with our stomachs growling i never want to have kids i say i might if i didnt live here says gale but you do i say irritated forget it he snaps back the conversation feels all wrong leave how could i leave prim who is the only person in the world im certain i love and gale is devoted to his family we cant leave so why bother talking about it and even if we did even if we did where did this stuff about having kids come from theres never been anything romantic between gale and me when we met i was a skinny twelveyearold and although he was only two years older he already looked like a man it took a long time for us to even become friends to stop haggling over every trade and begin helping each other out besides if he wants kids gale wont have any trouble finding a wife hes goodlooking hes strong enough to handle the work in the mines and he can hunt you can tell by the way the girls whisper about him when he walks by in school that they want him it makes me jealous but not for the reason people would think good hunting partners are hard to find what do you want to do i ask we can hunt fish or gather lets fish at the lake we can leave our poles and gather in the woods get something nice for tonight he says tonight after the reaping everyone is supposed to celebrate and a lot of people do out of relief that their children have been spared for another year but at least two families will pull their shutters lock their doors and try to figure out how they will survive the painful weeks to come we make out well the predators ignore us on a day when easier tastier prey abounds by late morning we have a dozen fish a bag of greens and best of all a gallon of strawberries i found the patch a few years ago but gale had the idea to string mesh nets around it to keep out the animals on the way home we swing by the hob the black market that operates in an abandoned warehouse that once held coal when they came up with a more efficient system that transported the coal directly from the mines to the trains the hob gradually took over the space most businesses are closed by this time on reaping day but the black markets still fairly busy we easily trade six of the fish for good bread the other two for salt greasy sae the bony old woman who sells bowls of hot soup from a large kettle takes half the greens off our hands in exchange for a couple of chunks of paraffin we might do a tad better elsewhere but we make an effort to keep on good terms with greasy sae shes the only one who can consistently be counted on to buy wild dog we dont hunt them on purpose but if youre attacked and you take out a dog or two well meat is meat once its in the soup 111 call it beef greasy sae says with a wink no one in the seam would turn up their nose at a good leg of wild dog but the peacekeepers who come to the hob can afford to be a little choosier when we finish our business at the market we go to the back door of the mayors house to sell half the strawberries knowing he has a particular fondness for them and can afford our price the mayors daughter madge opens the door shes in my year at school being the mayors daughter youd expect her to be a snob but shes all right she just keeps to herself like me since neither of us really has a group of friends we seem to end up together a lot at school eating lunch sitting next to each other at assemblies partnering for sports activities we rarely talk which suits us both just fine today her drab school outfit has been replaced by an expensive white dress and her blonde hair is done up with a pink ribbon reaping clothes pretty dress says gale madge shoots him a look trying to see if its a genuine compliment or if hes just being ironic itisa pretty dress but she would never be wearing it ordinarily she presses her lips together and then smiles well if i end up going to the capitol i want to look nice dont i now its gales turn to be confused does she mean it or is she messing with him im guessing the second you wont be going to the capitol says gale coolly his eyes land on a small circular pin that adorns her dress real gold beautifully crafted it could keep a family in bread for months what can you have five entries i had six when i was just twelve years old thats not her fault i say no its no ones fault just the way it is says gale madges face has become closed off she puts the money for the berries in my hand good luck katniss you too i say and the door closes we walk toward the seam in silence i dont like that gale took a dig at madge but hes right of course the reaping system is unfair with the poor getting the worst of it you become eligible for the reaping the day you turn twelve that year your name is entered once at thirteen twice and so on and so on until you reach the age of eighteen the final year of eligibility when your name goes into the pool seven times thats true for every citizen in all twelve districts in the entire country of panem but heres the catch say you are poor and starving as we were you can opt to add your name more times in exchange for tesserae each tessera is worth a meager years supply of grain and oil for one person you may do this for each of your family members as well so at the age of twelve i had my name entered four times once because i had to and three times for tesserae for grain and oil for myself prim and my mother in fact every year i have needed to do this and the entries are cumulative so now at the age of sixteen my name will be in the reaping twenty times gale who is eighteen and has been either helping or singlehandedly feeding a family of five for seven years will have his name in fortytwo times you can see why someone like madge who has never been at risk of needing a tessera can set him off the chance of her name being drawn is very slim compared to those of us who live in the seam not impossible but slim and even though the rules were set up by the capitol not the districts certainly not madges family its hard not to resent those who dont have to sign up for tesserae gale knows his anger at madge is misdirected on other days deep in the woods ive listened to him rant about how the tesserae are just another tool to cause misery in our district a way to plant hatred between the starving workers of the seam and those who can generally count on supper and thereby ensure we will never trust one another its to the capitols advantage to have us divided among ourselves he might say if there were no ears to hear but mine if it wasnt reaping day if a girl with a gold pin and no tesserae had not made what im sure she thought was a harmless comment as we walk i glance over at gales face still smoldering underneath his stony expression his rages seem pointless to me although i never say so its not that i dont agree with him i do but what good is yelling about the capitol in the middle of the woods it doesnt change anything it doesnt make things fair it doesnt fill our stomachs in fact it scares off the nearby game i let him yell though better he does it in the woods than in the district gale and i divide our spoils leaving two fish a couple of loaves of good bread greens a quart of strawberries salt paraffin and a bit of money for each see you in the square i say wear something pretty he says flatly at home i find my mother and sister are ready to go my mother wears a fine dress from her apothecary days prim is in my first reaping outfit a skirt and ruffled blouse its a bit big on her but my mother has made it stay with pins even so shes having trouble keeping the blouse tucked in at the back a tub of warm water waits for me i scrub off the dirt and sweat from the woods and even wash my hair to my surprise my mother has laid out one of her own lovely dresses for me a soft blue thing with matching shoes are you sure i ask im trying to get past rejecting offers of help from her for a while i was so angry i wouldnt allow her to do anything for me and this is something special her clothes from her past are very precious to her of course lets put your hair up too she says i let her toweldry it and braid it up on my head i can hardly recognize myself in the cracked mirror that leans against the wall you look beautiful says prim in a hushed voice and nothing like myself i say i hug her because i know these next few hours will be terrible for her her first reaping shes about as safe as you can get since shes only entered once i wouldnt let her take out any tesserae but shes worried about me that the unthinkable might happen i protect prim in every way i can but im powerless against the reaping the anguish i always feel when shes in pain wells up in my chest and threatens to register on my ace i notice her blouse has pulled out of her skirt in the back again and force myself to stay calm tuck your tail in little duck i say smoothing the blouse back in place prim giggles and gives me a smallquack quack yourself i say with a light laugh the kind only prim can draw out of me come on lets eat i say and plant a quick kiss on the top of her head the fish and greens are already cooking in a stew but that will be for supper we decide to save the strawberries and bakery bread for this evenings meal to make it special we say instead we drink milk from prims goat lady and eat the rough bread made from the tessera grain although no one has much appetite anyway at one oclock we head for the square attendance is mandatory unless you are on deaths door this evening officials will come around and check to see if this is the case if not youll be imprisoned its too bad really that they hold the reaping in the square — one of the few places in district 12 that can be pleasant the squares surrounded by shops and on public market days especially if theres good weather it has a holiday feel to it but today despite the bright banners hanging on the buildings theres an air of grimness the camera crews perched like buzzards on rooftops only add to the effect people file in silently and sign in the reaping is a good opportunity for the capitol to keep tabs on the population as well twelve through eighteenyear olds are herded into roped areas marked off by ages the oldest in the front the young ones like prim toward the back family members line up around the perimeter holding tightly to one anothers hands but there are others too who have no one they love at stake or who no longer care who slip among the crowd taking bets on the two kids whose names will be drawn odds are given on their ages whether theyre seam or merchant if they will break down and weep most refuse dealing with the racketeers but carefully carefully these same people tend to be informers and who hasnt broken the law i could be shot on a daily basis for hunting but the appetites of those in charge protect me not everyone can claim the same anyway gale and i agree that if we have to choose between dying of hunger and a bullet in the head the bullet would be much quicker the space gets tighter more claustrophobic as people arrive the squares quite large but not enough to hold district 12s population of about eight thousand latecomers are directed to the adjacent streets where they can watch the event on screens as its televised live by the state i find myself standing in a clump of sixteens from the seam we all exchange terse nods then focus our attention on the temporary stage that is set up before the justice building it holds three chairs a podium and two large glass balls one for the boys and one for the girls i stare at the paper slips in the girls ball twenty of them have katniss everdeen written on them in careful handwriting two of the three chairs fill with madges father mayor undersee whos a tall balding man and effie trinket district 12s escort fresh from the capitol with her scary white grin pinkish hair and spring green suit they murmur to each other and then look with concern at the empty seat just as the town clock strikes two the mayor steps up to the podium and begins to read its the same story every year he tells of the history of panem the country that rose up out of the ashes of a place that was once called north america he lists the disasters the droughts the storms the fires the encroaching seas that swallowed up so much of the land the brutal war for what little sustenance remained the result was panem a shining capitol ringed by thirteen districts which brought peace and prosperity to its citizens then came the dark days the uprising of the districts against the capitol twelve were defeated the thirteenth obliterated the treaty of treason gave us the new laws to guarantee peace and as our yearly reminder that the dark days must never be repeated it gave us the hunger games the rules of the hunger games are simple in punishment for the uprising each of the twelve districts must provide one girl and one boy called tributes to participate the twentyfour tributes will be imprisoned in a vast outdoor arena that could hold anything from a burning desert to a frozen wasteland over a period of several weeks the competitors must fight to the death the last tribute standing wins taking the kids from our districts forcing them to kill one another while we watch — this is the capitols way of reminding us how totally we are at their mercy how little chance we would stand of surviving another rebellion whatever words they use the real message is clear look how we take your children and sacrifice them and theres nothing you can do if you lift a finger we will destroy every last one of you just as we did in district thirteen to make it humiliating as well as torturous the capitol requires us to treat the hunger games as a festivity a sporting event pitting every district against the others the last tribute alive receives a life of ease back home and their district will be showered with prizes largely consisting of food all year the capitol will show the winning district gifts of grain and oil and even delicacies like sugar while the rest of us battle starvation it is both a time for repentance and a time for thanks intones the mayor then he reads the list of past district 12 victors in seventyfour years we have had exactly two only one is still alive haymitch abernathy a paunchy middle aged man who at this moment appears hollering something unintelligible staggers onto the stage and falls into the third chair hes drunk very the crowd responds with its token applause but hes confused and tries to give effie trinket a big hug which she barely manages to fend off the mayor looks distressed since all of this is being televised right now district 12 is the laughingstock of panem and he knows it he quickly tries to pull the attention back to the reaping by introducing effie trinket bright and bubbly as ever effie trinket trots to the podium and gives her signature happy...

Attachments:

Answers

(11)
Status NEW Posted 04 May 2017 06:05 AM My Price 12.00

-----------

Not Rated(0)