Part 1
Write a function destroyAllXs that, given a linked list of characters and a separate character, removes all Nodes with the given character from the list.
All remaining elements must appear in their original order.

Part 2
Write a function infinitySnap that, given a binary search tree, removes and puts half the tree nodes into a new tree, and returns both trees.
This snap, however, is not random and takes every node in an even position, given a pre-order depth-first traversal.
The first tree should have the nodes in the odd positions.
The second tree should have the nodes in the even positions.

Example: if the order was ['a', 'b', 'c', 'd'], tree1 would have'a' and "c", and tree2 would have 'b' and d'.
If the BST is empty, return None.
Make a second function endgameSnap that takes the two binary search trees and restores them to the original binary tree.

Write your own preorder function as part of and use that in your part 2 code.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import unittest
from node import Node
from treenode import TreeNode
from unorderedlist import UnorderedList
from binarysearchtree import BinarySearchTree

def destroyAllXs(linkedList, character):
    while(not linkedList.isEmpty() and

def preOrder(bst, lst):
    if bst is not None:

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats