QuestionQuestion

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 quiz6.py and use that in your part 2 code.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse 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 linkedList.search(character)):
       linkedList.remove(character)

def preOrder(bst, lst):
    if bst is not None:
       lst.append(bst)
       preOrder(bst....
$55.00 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.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
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