In both codes, the deleteValue method starts at the head of the linked list and searches for the first node with the specified value. If the value is found, the links of the surrounding nodes are updated to exclude the node with the specified value. If the node with the specified value is not found, an error message is printed.