Given a singly linked list consisting only of '(' and ')'. Write pseudocode, not exact code to
Fantastic news! We've Found the answer you've been seeking!
Question:
Given a singly linked list consisting only of '(' and ')'. Write pseudocode, not exact code to return if a list is balanced or not.
For Example:
Input: ( -> ( -> ) -> ( -> ) -> )
Output: True
Input: ( -> ( -> )
Output: False
Assume a reference pointer 'head' to the first node of the Linked List is already declared, and method size() returns the number of elements in the list. Refer to the Node class used in class.
Method Name: boolean isBalanced()
Input: None, Assume you are writing the method in LinkedList Class and the LinkedList is already created.
Output: True or False
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date: