Download presentation
Presentation is loading. Please wait.
1
1 Lab Session-12 CSIT221 Spring 2003 FINAL Lab Exercise Exercise is based on binary search tree (Demo Required)
2
2 Lab Exercise (Demo Due May 6 th Sec 01 and May 8 th Sec 02) You will develop a spell checker using BST’s. Build a dictionary BST for storing correctly spelled words. Change the info to string and include. You should use the member function definitions as given on the next slide so that you can focus on the spell- checker problem. Some member functions are blank as they are not needed in the spell- checker.
3
3 Class Header File //TreeNode definition goes here class TreeType { public: TreeType ( ) {root = NULL; } // constructor ~TreeType () {cout<<"destroy it"<<endl; } // dummy destructor bool IsEmpty ( ) const {return (root == NULL) ;} bool IsFull ( ) const {//try acquiring memory and return true if NULL was returned} int NumberOfNodes ( ) const { /*blank*/} //dummy function void InsertItem (string item) {//Use the function that you developed in worksheet 11} void RetrieveItem (string& item, bool& found) {//Use the function that was developed in class) private: TreeNode* root; };
4
4 Lab Exercise Description Use the sample text given on slide 6 for demo. Save it as a text file. Introduce at least 7 spelling errors in the words of the original file and save the modified text with a different name Open the original file and read and store all the different words from this file to your BST
5
5 Lab Exercise Run your spell checker on the modified file Your spell checker must capture the misspelled words and display them on the screen Can you give the user a hint to possible correct spelling of the misspelled words?
6
6 Sample Text File LOS ANGELES, California (AP) -- The murder rate rose nearly 11 percent last year in California's largest cities and counties, an increase officials say may be attributable to gang violence and a waning economy. The largest cities and counties reported 1,842 killings from January through December 2002 -- 179 more than in 2001, according to preliminary figures from the state attorney general's office. "We must never forget the pain that each of these killings causes for families and communities," Attorney General Bill Lockyer said Sunday in a statement. Overall, the number of reported major crimes in the state increased 3.8 percent. Murder, rape, robbery, burglary and vehicle theft figures all rose while aggravated assaults dropped 2.3 percent. The figures were for 78 areas with populations of 100,000 or more -- which together account for about 65 percent of the state's crime. The numbers were not adjusted for increases in population. A final report on statewide crime based on reports from more than 600 law enforcement agencies will be released this fall. Many major U.S. cities saw a drop in murders during the 1990s. In California, the rate of reported homicides decreased by 30 percent from 1996 to 2001. But in the past few years, the trend started to reverse itself as the economy dipped. After experiencing the largest ever one-year drop in California history of 14.9 percent in 1999, the state's major crime rate increased by 1 percent in 2000 and 3.7 percent in 2001. A few California cities improved last year. San Diego's 47 reported homicides represented a decrease of 6 percent. But Oakland had 108 killings, a 28.6-percent jump. Across the bay, San Francisco's figure was unchanged at 62 homicides. In Los Angeles, the most populous city, crime was up 1.8 percent overall and there were 653 homicides, a jump of 11.1 percent. Many recent killings in Los Angeles have been linked to gang violence. Police Chief William J. Bratton, a former New York police commissioner, has said he would make fighting gangs a priority. "Every day our kids are going to school, stepping over dead bodies," said LaWanda Hawkins, 47, of the San Pedro port area of Los Angeles. Her nonprofit group, Justice for Murdered Children, seeks to reduce the number of killings. Hawkins argued that there is a "culture of violence" in some poor areas of the city, in part because overworked police have failed to solve killings. While nowhere near the totals of the 1980s and early 1990s, Los Angeles' number was far higher than New York, which has more than twice the population. The number of homicides in New York City dropped to 580 for the year 2002, the lowest figure in 39 years. Chicago, the country's third-largest city, recorded about 645 homicides for 2002.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.