Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 894 Bytes

Ex_1_3_40.md

File metadata and controls

30 lines (18 loc) · 894 Bytes
title date draft tags categories
Algorithm4 Java Solution 1.3.40
2019-07-28 08:47:27 +0800
false
JAVA
TECH
archives

1.3.40

Problem:

Move-to-front. Read in a sequence of characters from standard input and maintain the characters in a linked list with no duplicates. When you read in a previously unseen character, insert it at the front of the list. When you read in a duplicate character, delete it from the list and reinsert it at the beginning. Name your program MoveToFront: it implements the well-known move-to-front strategy, which is useful for caching, data compression, and many other applications where items that have been recently accessed are more likely to be reaccessed

Solution:

code:

Ex_1_3_40.java

linked list add find() method, return a previous of the node if node.item equals given item.

Reference: