Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1: Create an optional small GUl program using javax.swing components or hav

ID: 3870706 • Letter: P

Question

Part 1: Create an optional small GUl program using javax.swing components or have a console output if you prefer not to create GUI. This is just a dummy Ul with no search capabilites in this Part 1 Word to search for. Data Structure Search WordNet Noun data structure ((computer science) the organization of data (and its storage allocations in a computer)) Part 2: A text file will be provided for the database of English words, their type (noun, verb, etc.) and their meaning. Create an efficient hash function to convert each word into an int Key: hash function int Note: the text file will containe single words or multiple words connected via underscore, the type of the word (noun, verb, etc) and its meaning. So if we search for Data Structure, we will find Data Structure which will be valid result to return. Part 3: Implement Linear Probing, Quadtratic Probing, Separate Chaining, Double Hashing techniques discussed in class. Chose an appropriate Lamda value per implementation. Use Key generation in part 2 to store the node (key, type, meaning) in the hash table Part 4: Once a word is searched, output its meaning and provide the information related to each specific implementation in the ouput. For example Word to search for Data Structure Search WordNet Noun . data structure ((computer science) the organization of data (and its storage allocations in a computer)) Total Words: XXXXXXX Data Structure Linear Probing Quadratic Probing Separate Chaining XXX Double Hashing: Table Size Lambda Items investigated Success Yes or No Yes or No Yes or No Yes or No XxX

Explanation / Answer

Part A :

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class SearchDemo{

private JLabel lblWordsType;

private JButton btnSearch;

private JLabel lblTotalWord;

public SearchDemo(){

prepareGUI();

}

public static void main(String[] args){

SearchDemo searchdemo= new SearchDemo();  

}

private void prepareGUI(){

JFrame frame=new JFrame();//creating instance of JFrame  

  

JLabel lblSearch =new JLabel("Word to Search for:");; //creating instance of JLabel  

lblSearch.setBounds(10,10,200, 40);//x axis, y axis, width, height  

  

JTextField txtSearch = new JTextField("Data Search");

txtSearch.setBounds(150,10,100,20);

btnSearch = new JButton("Search WordNet");

btnSearch.setBounds(250,10,200,20);

btnSearch.setActionCommand("Search");

btnSearch.addActionListener(new ButtonClickListener());

lblWordsType =new JLabel("Noun");; //creating instance of JLabel  

lblWordsType.setBounds(10,50,200, 40);//x axis, y axis, width, height  

JLabel lblResult =new JLabel("data structure ((computer science)) the organization of data (and its storage allocations in a computer");; //creating instance of JLabel. set search result into this label.

lblResult.setBounds(10,70,1000, 40);//x axis, y axis, width, height  

lblTotalWord = new JLabel("Total Words:");// for showing total words

lblTotalWord.setBounds(10,90,200, 40);

frame.add(lblSearch);//adding Label in JFrame  

frame.add(txtSearch);//adding TextField in JFrame  

frame.add(btnSearch);//adding Button in JFrame

frame.add(lblWordsType);//adding Label in JFrame

frame.add(lblResult);//adding Label in JFrame

frame.add(lblTotalWord);//adding Label in JFrame

frame.setSize(400,500);//400 width and 500 height  

frame.setLayout(null);//using no layout managers  

frame.setVisible(true);//making the frame visible

}

private int WordIntoHash(String words){

int hash = 3;

int strlen= words.length();

for (int i = 0; i < strlen; i++) {

hash = hash*31 + charAt(i);

}

return hash;

}

  

private class ButtonClickListener implements ActionListener{

public void actionPerformed(ActionEvent e) {

String command = e.getActionCommand();  

if( command.equals( "Search" )) {

  

}

}

}

}