Akhil-Data-Structures

Github Pages - Data Structures 1


Project maintained by AkhilNandhakumar Hosted on GitHub Pages — Theme by mattgraham

Navbar

Home/Current Proj. TPT Notes Data Struc. Work Create Task AP Prep and Plan Past Projects

Create Task Documentation


Site Search Feature

Final Commited Code

Interactive Runtime Found Here: Website

3A

Overall purpose: Navigate our Beach Resource Website easier by searching for pages. Functionality/Input: Input text and submit into a search bar which returns a rendered HTML page based on what was searched for. Inputted invalid request for a page that does not exist and an error message is displayed with a prompt that includes an example of what to search for. Input/Output: Text is inputted, rendered HTML page or error message is outputted.

3B

Storing Data in a List:

Screen Shot 2022-02-14 at 11 07 01 AM

Using the Data:

Screen Shot 2022-02-14 at 11 08 21 AM

The list being used in this example is beach pages. The other lists can be used by changing the function’s used parameter value. The data in the list is organized as a dictionary, and each item in the list represents the name of one of the beach pages and its corresponding URL. The list is used to manage complexity by organizing all of the pages into a list that can be iterated through. This makes searching for the desired list easy by iterating through each item and checking whether it matches the user’s input. Without using a list like this, searching all of the pages and their URLs would not be possible.

3C

Procedure:

Screen Shot 2022-02-14 at 11 16 09 AM

Calling the procedure:

Screen Shot 2022-02-14 at 11 17 17 AM

The general function of the procedure recognizes the user’s input into a text box, searches the dictionary for a matching beach page, and returns the link of the page.

Detailed Description: variable “x” contains the dictionary data as JSON information. Variable “input” gets the user’s input from the HTML search bar with the id “beach search”. The input is turned to lowercase to prevent case sensitivity. A for loop sets an index marker at position 0, and loops the following instructions n number of times where n is the length of the list “beach pages”: The algorithm checks if the substring of the input from index 0 to the length of the input matches any item in the dictionary using the same substring method. This allows a valid return even if the user does not enter the entire name of the page. If true, the variable “link” gets assigned to the corresponding URL page and is returned. If none of the items in the list match the input, an error message is displayed and gives an example using a random number function to pick a random index in the valid list to display as an example.

3D

Call 1: Search bar takes the input of “Del Mar Beach”, while function takes a parameter “beach pages”, and submit button is pressed. Condition tested by the first call is if the input matches an item in the “beach pages” list. The result of this call would return a rendered page with the URL “/del-mar-beach/”, and display the page.

Call 2: Search bar takes the input of “Pacific Beach”, while function takes a parameter “about pages”, and submit button is pressed. Condition tested by the second call is if the input matches an item in the “about pages” list. The result of the call would not find a matching page in the list, and run the error code block, by returning the same page, and displaying an error message saying, “Page Does Not Exist. Please search for pages similar to: “ and provides a random example of a page in “about pages”.