Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Simple program that involves certain algorithms

Hey all,

So our algorthims teacher asked us to make a simple project (program) in java that would involve one of the topics that we learnt during the semester but I have no idea what to do. So we learnt about some string search/sorting algorithms like LSD, MSD, Bruteforce, Knuth-Morris-Pratt (DFA), boyer-moore alg and rabin karp. So what I'm asking is if you have any idea what could I do or if you have any source to get some ideas. It doesn't necessarily have to be complicated (it can be as easy as selecting a file and sorting it using DFS or something).

I'd really appreciate your help, have a nice day all. 🤝
A simple program would be sorting a text file where each line contains a string, you could use any sorting algorithm for this such as merge sort.

Something more advanced would be using BFS or DFS to solve a maze, but you would need to generate your own maze or find an existing maze for this.
Here are some ideas that might help to get you started.

Depth first search / Breadth first search:

I'm a traveller, looking for flights to catch until I reach my destination. The question that I'm faced with, is what the route is that I can take that takes the least amount of time in order to get to my destination. I don't care how many times I have to switch flights.
Each node (as seen on the graph below) can be seen as a change of flights. Each node holds a specific score, this represents the amount of time it takes to get to that point. The end node of every branch can be seen as the destination, but holds a different score depending on the previous node (Obviously, because travelling from Paris to Amsterdam takes less time than travelling from New York to Amsterdam).

An example of flight paths:
[Image: Screen%2BShot%2B2015-12-27%2Bat%2B11.19.48%2Bpm.png]

If you can, please create a version of this which utilizes an A* algorithm to perform the search.
Also, if possible, please explain to me why both methods (DFS/BFS) are imperfect/incorrect for this particular use case.

Helping materials:
https://stackabuse.com/graphs-in-java-de...earch-dfs/
https://stackabuse.com/graphs-in-java-br...earch-bfs/

Bruteforce:
Consider the following example character set:
Code
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

I'd like to see a list of unique strings that you can generate that are formatted in the following fashion:
Code
[A-Z][A-Z][A-Z]-[0-9][0-9][0-9]-[A-Z][A-Z][A-Z]

Example output:
Code
AAA-000-AAAA
AAA-000-AAAB

Hint (C#):
https://hackforums.net/showthread.php?ti...id59087444
[Image: vp6iypF.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by BarretMar 10, 2019 11:58 AM 3 471 Mar 10, 2019 11:58 AM
Last Post: 0xDEAD10CC
[Java] by c-_-mMar 19, 2017 02:36 PM 7 594 Mar 19, 2017 02:36 PM
Last Post: Stealth™
[Java] by c-_-mMar 15, 2017 09:17 AM 0 198 Mar 15, 2017 09:17 AM
Last Post: c-_-m